diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0.sql index f64e9d783a..71afd70c29 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0_optimized.sql index 3993f1f53d..46f4788fed 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0.sql index 0ab7ede8ba..57643a5173 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index 807f435fb6..cf28a553fe 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0.sql index eb8fe6f326..1d18ac9b38 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS FLOAT64) / CAST(NULLIF(subq_17.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate + CAST(subq_16.buys AS FLOAT64) / CAST(NULLIF(subq_16.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , GENERATE_UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0_optimized.sql index 0b439309dc..3393b03c17 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_23.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_21.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index 10acbd5108..2e35d6c3f6 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , GENERATE_UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_8.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index ba0d16bcae..99fe8a537c 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > DATE_SUB(CAST(subq_30.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_25.metric_time__day > DATE_SUB(CAST(subq_28.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql index 5ef6fe4b8f..4009c68530 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql index c1b542f31b..c4ecca9044 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0.sql index 78f8dcf88e..c29b146cf0 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0_optimized.sql index ca2043d15a..9fed053a9c 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 4860cd1c7a..e5d0cc740f 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 37edde3003..42a7790086 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0.sql index 0028b9222e..dba4d843e0 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0_optimized.sql index b505bce110..9e93193c3e 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0.sql index 7a9a47a013..1a7efd93c2 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index 422c4c20a2..40fb87b79a 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0.sql index bbecf3aaee..2c8dfb4622 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0_optimized.sql index 5d6858783d..6edcac7975 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_23.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_21.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index 5f54fb7bb9..56e7a55442 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index 302e16601a..1e540c2689 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > DATEADD(day, -7, subq_30.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql index 54983cfa14..edbf9c54a0 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql index eb6e9d118e..985f0a99e9 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0.sql index 86205d10ff..86aa0b350b 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0_optimized.sql index 910821a21e..1302b3d040 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 249aa1b2a7..5893a4e610 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index ed73a71cb4..eba30fadc6 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0.sql index 92f4a2f1f6..e31bbd0ca8 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0_optimized.sql index 8055fd4d42..8d2a141ee1 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0.sql index dcd98c5e5f..fafe48fda9 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index a66fd2b99d..e8dd581b01 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0.sql index 226fa0a589..afe24609a4 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0_optimized.sql index 289c2a1075..db2e8ca660 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_23.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_21.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index daff97f0b9..15847b2f1d 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > subq_12.metric_time__day - MAKE_INTERVAL(days => 7) + subq_8.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index cb8c9f14fd..e0ba2bde48 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > subq_30.metric_time__day - MAKE_INTERVAL(days => 7) + subq_25.metric_time__day > subq_28.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql index b3dad74474..13a210cc87 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql index f778c3d079..fd39950653 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0.sql index 6ae1ba7530..ad99382b42 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0_optimized.sql index 174d46f7f7..4eea2fff8e 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 4ef799b033..ef92a10f35 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 4974362e75..ba50c1da38 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0.sql index 23a3bbba01..2b9f26acfb 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0_optimized.sql index 8e5ce0b802..8e716dd9d0 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0.sql index 142d78c76d..6aa7d0efa8 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index c7dc051cac..d30d5419ad 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0.sql index 5702cf7e7a..38f395b85b 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.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_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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0_optimized.sql index 3ea97b9be7..d7c9cee347 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_23.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_21.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index 11e25eddc4..f370714730 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.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_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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index a81c77f438..581e6904a4 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > DATEADD(day, -7, subq_30.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql index 13407ae830..e3dc18de5c 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 7823e08bcb..d50f2f65cb 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0.sql index 277117dbeb..e8b37ff907 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0_optimized.sql index ef39b6eacb..848cfcda4f 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql index efa1d87f04..24fb22698f 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index 7da1f4f2f5..3bf1885e34 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0.sql index 0090c0fdd3..20aea8ac32 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0_optimized.sql index 030bc65e29..418f779dc4 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0.sql index e40e39a3d6..5bfd04c6eb 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index bd6b7642bb..c60e292914 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0.sql index 855b19356f..5e4e7f7193 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , UUID_STRING() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0_optimized.sql index 91b676fb10..ffec593847 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_23.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_21.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index 7e84512ccc..d38a6397b5 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , UUID_STRING() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index 32c69c4fdd..615d55e244 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > DATEADD(day, -7, subq_30.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql index 9e486ac09f..287ae4bafc 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql index e30a42131e..b7866da040 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0.sql index 8f8ecebf1d..08455330a8 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0_optimized.sql index 094ce6b413..ef268f3858 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql index 8bf1d9f0a6..ce1dfd5532 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN '2020-01-01' AND '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index b3be8e9782..6276a9f1eb 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0.sql index e5787d0dd5..41e61a7a80 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0_optimized.sql index dae9de1494..03486b0bcb 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0.sql index d43945d934..7e2dacfe75 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_3.visit__referrer_id , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visit__referrer_id , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -108,8 +146,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE visit__referrer_id = 'ref_id_01' ) subq_2 - WHERE visit__referrer_id = 'ref_id_01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0_optimized.sql index 79f7e7d849..2f21607f4f 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_categorical_filter__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -20,13 +21,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0.sql index 0224335d18..dd1cd79886 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0.sql @@ -1,252 +1,285 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , MAX(subq_16.buys) AS buys + MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE metric_time__day = '2020-01-01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of INF SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -281,120 +314,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE metric_time__day = '2020-01-01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , uuid() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -440,17 +473,17 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) + (subq_8.metric_time__day <= subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0_optimized.sql index c1320713b5..8828f1ee14 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_34.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_23.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate + CAST(MAX(subq_32.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_21.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE metric_time__day = '2020-01-01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys',] @@ -28,38 +27,38 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -69,9 +68,9 @@ CROSS JOIN ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE metric_time__day = '2020-01-01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -82,12 +81,12 @@ CROSS JOIN ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( - (subq_27.metric_time__day <= subq_30.metric_time__day) + (subq_25.metric_time__day <= subq_28.metric_time__day) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0.sql index 9efcbd7cd4..232d0421de 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0.sql @@ -1,262 +1,295 @@ -- Compute Metrics via Expressions SELECT - subq_17.buys AS visit_buy_conversions + subq_16.buys AS visit_buy_conversions FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_5.visits) AS visits - , COALESCE(MAX(subq_16.buys), 0) AS buys + MAX(subq_4.visits) AS visits + , COALESCE(MAX(subq_15.buys), 0) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_4.visits) AS visits + SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_3.visits + subq_2.visits FROM ( -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id - , subq_2.visits + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id + , subq_1.visits + , subq_1.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.visit__referrer_id - , subq_1.visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 + 1 AS visits + , 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_0 + ) subq_1 WHERE visit__referrer_id = 'ref_id_01' - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_15.buys) AS buys + SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_14.buys + subq_13.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.visit__referrer_id - , subq_13.buys - , subq_13.visits + subq_12.metric_time__day + , subq_12.user + , subq_12.visit__referrer_id + , subq_12.buys + , subq_12.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( + FIRST_VALUE(subq_8.visits) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_9.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_8.visit__referrer_id) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_9.metric_time__day) OVER ( + , FIRST_VALUE(subq_8.metric_time__day) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( + , FIRST_VALUE(subq_8.user) OVER ( PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visit__referrer_id - , subq_8.visits + subq_7.metric_time__day + , subq_7.user + , subq_7.visit__referrer_id + , subq_7.visits FROM ( -- Constrain Output with WHERE SELECT - subq_7.ds__day - , subq_7.ds__week - , subq_7.ds__month - , subq_7.ds__quarter - , subq_7.ds__year - , subq_7.ds__extract_year - , subq_7.ds__extract_quarter - , subq_7.ds__extract_month - , subq_7.ds__extract_day - , subq_7.ds__extract_dow - , subq_7.ds__extract_doy - , subq_7.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.metric_time__day - , subq_7.metric_time__week - , subq_7.metric_time__month - , subq_7.metric_time__quarter - , subq_7.metric_time__year - , subq_7.metric_time__extract_year - , subq_7.metric_time__extract_quarter - , subq_7.metric_time__extract_month - , subq_7.metric_time__extract_day - , subq_7.metric_time__extract_dow - , subq_7.metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.metric_time__day + , subq_6.metric_time__week + , subq_6.metric_time__month + , subq_6.metric_time__quarter + , subq_6.metric_time__year + , subq_6.metric_time__extract_year + , subq_6.metric_time__extract_quarter + , subq_6.metric_time__extract_month + , subq_6.metric_time__extract_day + , subq_6.metric_time__extract_dow + , subq_6.metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( -- 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.visit__ds__day - , subq_6.visit__ds__week - , subq_6.visit__ds__month - , subq_6.visit__ds__quarter - , subq_6.visit__ds__year - , subq_6.visit__ds__extract_year - , subq_6.visit__ds__extract_quarter - , subq_6.visit__ds__extract_month - , subq_6.visit__ds__extract_day - , subq_6.visit__ds__extract_dow - , subq_6.visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user - , subq_6.session - , subq_6.visit__user - , subq_6.visit__session - , subq_6.referrer_id - , subq_6.visit__referrer_id - , subq_6.visits - , subq_6.visitors + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.visit__ds__day + , subq_5.visit__ds__week + , subq_5.visit__ds__month + , subq_5.visit__ds__quarter + , subq_5.visit__ds__year + , subq_5.visit__ds__extract_year + , subq_5.visit__ds__extract_quarter + , subq_5.visit__ds__extract_month + , subq_5.visit__ds__extract_day + , subq_5.visit__ds__extract_dow + , subq_5.visit__ds__extract_doy + , subq_5.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.user + , subq_5.session + , subq_5.visit__user + , subq_5.visit__session + , subq_5.referrer_id + , subq_5.visit__referrer_id + , subq_5.visits + , subq_5.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -291,120 +324,120 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 WHERE visit__referrer_id = 'ref_id_01' - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 INNER JOIN ( -- Add column with generated UUID SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers , uuid() AS mf_internal_uuid 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -450,21 +483,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 + ) subq_11 ON ( - subq_9.user = subq_12.user + subq_8.user = subq_11.user ) AND ( ( - subq_9.metric_time__day <= subq_12.metric_time__day + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - subq_9.metric_time__day > DATE_ADD('day', -7, subq_12.metric_time__day) + subq_8.metric_time__day > DATE_ADD('day', -7, subq_11.metric_time__day) ) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 -) subq_17 + ) subq_12 + ) subq_13 + ) subq_14 + ) subq_15 +) subq_16 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql index 77df50308a..c5d4d76435 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - COALESCE(MAX(subq_34.buys), 0) AS visit_buy_conversions + COALESCE(MAX(subq_32.buys), 0) AS visit_buy_conversions FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -11,14 +11,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_18 WHERE visit__referrer_id = 'ref_id_01' -) subq_23 +) subq_21 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -28,46 +27,46 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_27.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_27.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_25.visit__referrer_id) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_27.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_27.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_30.user - , subq_30.metric_time__day - , subq_30.mf_internal_uuid - ORDER BY subq_27.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_30.mf_internal_uuid AS mf_internal_uuid - , subq_30.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_25.user + , subq_23.user , visit__referrer_id , visits FROM ( @@ -79,9 +78,9 @@ CROSS JOIN ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_23 WHERE visit__referrer_id = 'ref_id_01' - ) subq_27 + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -92,16 +91,16 @@ CROSS JOIN ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_30 + ) subq_28 ON ( - subq_27.user = subq_30.user + subq_25.user = subq_28.user ) AND ( ( - subq_27.metric_time__day <= subq_30.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_27.metric_time__day > DATE_ADD('day', -7, subq_30.metric_time__day) + subq_25.metric_time__day > DATE_ADD('day', -7, subq_28.metric_time__day) ) ) - ) subq_31 -) subq_34 + ) subq_29 +) subq_32 diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql index 815f59d813..bafac5df4e 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id'] + -- Constrain Output with WHERE SELECT - subq_2.visit__referrer_id + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -149,8 +188,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql index 4599e2f06a..ed1a96751f 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_time_constraint__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id'] -- Aggregate Measures SELECT visit__referrer_id @@ -18,13 +19,12 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id'] SELECT referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY visit__referrer_id diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0.sql index 1c1e24f03a..485cfd6a9a 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0.sql @@ -14,15 +14,54 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.visit__ds__day + , subq_1.visit__ds__week + , subq_1.visit__ds__month + , subq_1.visit__ds__quarter + , subq_1.visit__ds__year + , subq_1.visit__ds__extract_year + , subq_1.visit__ds__extract_quarter + , subq_1.visit__ds__extract_month + , subq_1.visit__ds__extract_day + , subq_1.visit__ds__extract_dow + , subq_1.visit__ds__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.user + , subq_1.session + , subq_1.visit__user + , subq_1.visit__session + , subq_1.referrer_id + , subq_1.visit__referrer_id , subq_1.visits + , subq_1.visitors FROM ( -- Metric Time Dimension 'ds' SELECT @@ -103,8 +142,8 @@ FROM ( FROM ***************************.fct_visits visits_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' ) subq_2 - WHERE metric_time__day = '2020-01-01' ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0_optimized.sql index c2bb12228f..3435f7cc4a 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_32.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -17,12 +18,11 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_19 + ) subq_18 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql index ee75dfc174..4e802eb75b 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0.sql @@ -17,17 +17,55 @@ FROM ( , subq_4.visit__referrer_id , SUM(subq_4.visits) AS visits FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT subq_3.metric_time__day , subq_3.visit__referrer_id , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_2.metric_time__day + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id , subq_2.visit__referrer_id , subq_2.visits + , subq_2.visitors FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT @@ -154,8 +192,8 @@ FROM ( ) subq_1 WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' ) subq_2 + WHERE visit__referrer_id = 'ref_id_01' ) subq_3 - WHERE visit__referrer_id = 'ref_id_01' ) subq_4 GROUP BY subq_4.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql index bd9af3b63c..a573ea1b51 100644 --- a/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metric_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_with_window_and_time_constraint__plan0_optimized.sql @@ -12,6 +12,7 @@ FROM ( , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,14 +22,13 @@ FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-02' - ) subq_22 + ) subq_21 WHERE visit__referrer_id = 'ref_id_01' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 0659795b5c..b841334dd6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a8dadf176f..1288af43aa 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index aaa5f4c03b..e463f8a456 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index eed113f868..5e9134eca7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_11.ds AS DATETIME), INTERVAL 2 day) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index 0fb334ddbe..9b5da71e24 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > DATE_SUB(CAST(subq_3.metric_time__day AS DATETIME), INTERVAL 2 month) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 88ef795b84..880c0ae9d3 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index ba616b7c75..678f39d46a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..95cd5a77bb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 867b8e2db7..3b86722112 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY subq_6.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..82901603c1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index d8233fe4a6..45b779624e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..4743faf42b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 8af29da836..d940d9ce44 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..95cd5a77bb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index aa45e34cfc..a2dd8a21e1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY subq_6.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 4bb70a61f7..0b6dc47704 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_11.ds - MAKE_INTERVAL(days => 2) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index a77410e810..ad1284e5f9 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > subq_3.metric_time__day - MAKE_INTERVAL(months => 2) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 6df10259be..9e47224fef 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index cdbc74960f..8ea5031611 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..95cd5a77bb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 9d307a8702..42ab20d4b7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY subq_6.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..82901603c1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index 83bca27502..5cca84c02a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..4743faf42b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index bc939ab7fb..7d58e6c138 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..95cd5a77bb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index c85fb774a3..d5fe0c4cad 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY subq_6.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..82901603c1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index 1a6cd4c601..65c43cc611 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > DATEADD(month, -2, subq_3.metric_time__day) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..4743faf42b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index cd2967d1e1..e930d1463c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -177,8 +211,8 @@ FROM ( ON (subq_2.metric_time__day <= subq_3.metric_time__day) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 5f0ebfafd1..eab1fc1814 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 5590d25022..3c00149d8a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -8,15 +8,111 @@ FROM ( subq_6.metric_time__day , COUNT(DISTINCT subq_6.bookers) AS bookers FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_5.metric_time__day , subq_5.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_4.metric_time__day + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( -- Join Self Over Time Range SELECT @@ -326,8 +422,8 @@ FROM ( subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) ) ) subq_4 + WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_5 - WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' ) subq_6 GROUP BY subq_6.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index e51229645c..47ec39dda7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -1,4 +1,5 @@ -- Constrain Output with WHERE +-- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -6,7 +7,6 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_11.ds AS metric_time__day , bookings_source_src_28000.guest_id AS bookers @@ -19,7 +19,7 @@ FROM ( ) AND ( DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_11.ds) ) -) subq_13 +) subq_12 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql index 7ea5b21ac4..3356983516 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql @@ -8,14 +8,48 @@ FROM ( subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( - -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] + -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_5.metric_time__day + 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.revenue_instance__ds__day + , subq_5.revenue_instance__ds__week + , subq_5.revenue_instance__ds__month + , subq_5.revenue_instance__ds__quarter + , subq_5.revenue_instance__ds__year + , subq_5.revenue_instance__ds__extract_year + , subq_5.revenue_instance__ds__extract_quarter + , subq_5.revenue_instance__ds__extract_month + , subq_5.revenue_instance__ds__extract_day + , subq_5.revenue_instance__ds__extract_dow + , subq_5.revenue_instance__ds__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.revenue_instance__user , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -181,8 +215,8 @@ FROM ( subq_2.metric_time__day > DATE_ADD('month', -2, subq_3.metric_time__day) ) ) subq_5 + WHERE subq_5.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_6 - WHERE subq_6.metric_time__day BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' ) subq_7 GROUP BY subq_7.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 14fdc3b055..997aa05a5d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -1,6 +1,6 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0.sql index cbe0194542..33874d3246 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS FLOAT64) / CAST(NULLIF(subq_18.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS FLOAT64) / CAST(NULLIF(subq_16.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY metric_time__martian_day - ) subq_5 + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , GENERATE_UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , buys_source_src_28000.user_id AS buyers - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , buys_source_src_28000.user_id AS buyers + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 7 day) - ) + subq_8.metric_time__day > DATE_SUB(CAST(subq_11.metric_time__day AS DATETIME), INTERVAL 7 day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY metric_time__martian_day - ) subq_17 + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY metric_time__martian_day -) subq_18 +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index 98b6848b95..5a1e87e48b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY metric_time__martian_day - ) subq_24 + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATETIME_TRUNC(ds, day) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > DATE_SUB(CAST(subq_31.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_25.metric_time__day > DATE_SUB(CAST(subq_28.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY metric_time__martian_day -) subq_37 +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0.sql index dab3e6cd04..e4755407bc 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS FLOAT64) / CAST(NULLIF(subq_20.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS FLOAT64) / CAST(NULLIF(subq_18.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY metric_time__martian_day - ) subq_6 + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers + , GENERATE_UUID() AS mf_internal_uuid + 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , GENERATE_UUID() AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , buys_source_src_28000.user_id AS buyers - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , buys_source_src_28000.user_id AS buyers + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 7 day) - ) + subq_10.metric_time__day > DATE_SUB(CAST(subq_13.metric_time__day AS DATETIME), INTERVAL 7 day) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY metric_time__martian_day - ) subq_19 + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY metric_time__martian_day -) subq_20 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index 3349e54e26..e35b9482d9 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATETIME_TRUNC(ds, day) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > DATE_SUB(CAST(subq_35.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_29.metric_time__day > DATE_SUB(CAST(subq_32.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY metric_time__martian_day -) subq_41 +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 92b241948e..004d675b99 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS FLOAT64) / CAST(NULLIF(subq_19.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS FLOAT64) / CAST(NULLIF(subq_18.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers , GENERATE_UUID() AS mf_internal_uuid 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_10.metric_time__day > DATE_SUB(CAST(subq_13.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index d7abc958f3..f84bb2c2ac 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_26.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS FLOAT64) / CAST(NULLIF(MAX(subq_24.visits), 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATETIME_TRUNC(ds, day) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > DATE_SUB(CAST(subq_34.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_29.metric_time__day > DATE_SUB(CAST(subq_32.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0.sql index 982dfad56d..4d95e26769 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 month) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 551590d951..b642dbbd73 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,32 +9,27 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_13.ds - ) AND ( - DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 month) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_13.ds + ) AND ( + DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 month) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY metric_time__martian_day , metric_time__day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0.sql index a2c5358788..7a2d4eb72c 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY booking__ds__martian_day - ) subq_5 - ) subq_6 + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY booking__ds__martian_day - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY booking__ds__martian_day -) subq_14 +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 735d87a4ae..51b05a38ec 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATETIME_TRUNC(bookings_source_src_28000.ds, day) = subq_17.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) = subq_14.ds GROUP BY booking__ds__martian_day -) subq_21 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index f7845ebe68..7ba592ec83 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY metric_time__martian_day , listing__ds__month -) subq_5 +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 9c045ac2f3..eea2d8665d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(created_at, month) AS listing__ds__month - , DATETIME_TRUNC(created_at, day) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATETIME_TRUNC(created_at, day) AS ds__day + , DATETIME_TRUNC(created_at, month) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY metric_time__martian_day , listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0.sql index 2e14ca1db3..fec26bde21 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY metric_time__martian_day - ) subq_5 -) subq_6 + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY metric_time__martian_day - ) subq_12 -) subq_13 + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index bf0346e7f9..ec46182df0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY metric_time__martian_day -) subq_20 +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(created_at, day) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATETIME_TRUNC(created_at, day) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY metric_time__martian_day -) subq_27 +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql index 57dffdac2f..d2972ba7a4 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATETIME_TRUNC(subq_2.booking__ds__day, isoweek) AS booking__ds__week + , DATETIME_TRUNC(subq_2.booking__ds__day, month) AS booking__ds__month + , DATETIME_TRUNC(subq_2.booking__ds__day, quarter) AS booking__ds__quarter + , DATETIME_TRUNC(subq_2.booking__ds__day, year) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.booking__ds__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.booking__ds__day) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATETIME_TRUNC(subq_2.booking__ds__day, isoweek) AS booking__ds__week - , DATETIME_TRUNC(subq_2.booking__ds__day, month) AS booking__ds__month - , DATETIME_TRUNC(subq_2.booking__ds__day, quarter) AS booking__ds__quarter - , DATETIME_TRUNC(subq_2.booking__ds__day, year) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM subq_2.booking__ds__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.booking__ds__day) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ON - DATE_SUB(CAST(subq_2.booking__ds__day AS DATETIME), INTERVAL 5 day) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 + ON + DATE_SUB(CAST(subq_2.booking__ds__day AS DATETIME), INTERVAL 5 day) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY booking__ds__martian_day - ) subq_8 -) subq_9 + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0_optimized.sql index 413cc81b20..d906db67ff 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - SELECT - DATETIME_TRUNC(ds, day) AS booking__ds__day - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 - ON - DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 5 day) = subq_11.booking__ds__day - ) subq_14 + DATETIME_TRUNC(ds, day) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + DATE_SUB(CAST(subq_12.ds AS DATETIME), INTERVAL 5 day) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY booking__ds__martian_day -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 0ab29abece..e7f68c5d33 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week - , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month - , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter - , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow - , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 + ON + DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY metric_time__day - ) subq_9 -) subq_10 + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index c425db79fa..5f9559f913 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ON - DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 5 day) = subq_12.metric_time__day - ) subq_15 + DATETIME_TRUNC(ds, day) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 5 day) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0.sql index d2c55567a2..48bb23dd1b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY booking__ds__martian_day -) subq_5 +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0_optimized.sql index 2c25cbdfe3..ed3b100a18 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATETIME_TRUNC(ds, day) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY booking__ds__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0.sql index a1794fdf6e..fe257d1e47 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY listing__ds__martian_day -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index 34df231155..3083f4cb9a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATETIME_TRUNC(listings_latest_src_28000.created_at, day) = subq_14.ds GROUP BY listing__ds__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0.sql index 49cb4e49a6..50140af38e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 27dd4bbc00..a3c6d55031 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index 2561a13561..e575d0735f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY metric_time__martian_day -) subq_6 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 073abe93ed..e2b0691009 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATETIME_TRUNC(ds, day) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATETIME_TRUNC(ds, day) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index 36a7279e19..a0052acfab 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY listing__user__ds__martian_day -) subq_14 +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 9e0fb7f048..c1d597284a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATETIME_TRUNC(ds_partitioned, day) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATETIME_TRUNC(ds_partitioned, day) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY listing__user__ds__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0.sql index f6cb5d8801..c50e43a2be 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 + subq_3.metric_time__martian_day + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) - ) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - subq_16.metric_time__martian_day - ) subq_17 + subq_14.metric_time__martian_day + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) -) subq_18 + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index 1ccc908d19..1727263c01 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY - subq_21.martian_day - ) subq_24 + subq_18.martian_day + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > DATEADD(day, -7, subq_31.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) -) subq_37 + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0.sql index cba3e8542c..18e65b327b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS DOUBLE) / CAST(NULLIF(subq_20.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day - ) subq_6 + subq_4.metric_time__martian_day + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers + , UUID() AS mf_internal_uuid + 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , UUID() AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) - ) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY - subq_18.metric_time__martian_day - ) subq_19 + subq_16.metric_time__martian_day + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) -) subq_20 + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index c2749cfd07..88bf6868bf 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > DATEADD(day, -7, subq_35.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) -) subq_41 + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 2be884bf09..6e31826903 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS DOUBLE) / CAST(NULLIF(subq_19.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers , UUID() AS mf_internal_uuid 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index ae9f966cae..1b55441cf6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_26.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_24.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > DATEADD(day, -7, subq_34.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0.sql index 13af74695a..46cf1d0b82 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > DATEADD(month, -2, subq_2.metric_time__day) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY subq_6.metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 6907f4775e..97db43cbe1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,35 +9,30 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds - ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds + ) AND ( + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY - subq_15.martian_day - , subq_14.metric_time__day + subq_14.martian_day + , subq_13.ds ) subq_17 ) subq_19 GROUP BY diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0.sql index 129ab49a97..60689b5662 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day - ) subq_5 - ) subq_6 + subq_3.booking__ds__martian_day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.booking__ds__martian_day - ) subq_12 - ) subq_13 + subq_9.booking__ds__martian_day + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) -) subq_14 + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 3bc3f746f5..d315d358a7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_14.ds GROUP BY - subq_17.martian_day -) subq_21 + subq_14.martian_day +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index 545d9ff874..da0f432abe 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - , subq_4.listing__ds__month -) subq_5 + subq_3.metric_time__martian_day + , subq_3.listing__ds__month +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 2f45574e41..091f68a2c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('month', created_at) AS listing__ds__month - , DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day + , DATE_TRUNC('month', created_at) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY - subq_8.martian_day - , subq_7.listing__ds__month + subq_6.martian_day + , subq_5.listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0.sql index e74af248da..551f54105c 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 -) subq_6 + subq_3.metric_time__martian_day + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.metric_time__martian_day - ) subq_12 -) subq_13 + subq_9.metric_time__martian_day + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index e5b55102e9..ae8868ac3d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY - subq_16.martian_day -) subq_20 + subq_13.martian_day +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY - subq_23.martian_day -) subq_27 + subq_19.martian_day +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql index 04163065f6..6e94458011 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week + , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month + , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter + , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.booking__ds__day) AS booking__ds__extract_dow + , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week - , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month - , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter - , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_2.booking__ds__day) AS booking__ds__extract_dow - , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY - subq_7.booking__ds__martian_day - ) subq_8 -) subq_9 + subq_6.booking__ds__martian_day + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0_optimized.sql index 0eeb6b2bc0..0be3ead6fd 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - 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_28000 - ) subq_11 - ON - DATEADD(day, -5, subq_13.ds) = subq_11.booking__ds__day - ) subq_14 + DATE_TRUNC('day', ds) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + DATEADD(day, -5, subq_12.ds) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY - subq_15.martian_day -) subq_19 + subq_13.martian_day +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index cbd13009d7..af4ab5dc6a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index ed5c7dd88f..21e34e9859 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - 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_28000 - ) subq_12 - ON - DATEADD(day, -5, subq_14.ds) = subq_12.metric_time__day - ) subq_15 + DATE_TRUNC('day', ds) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + DATEADD(day, -5, subq_13.ds) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0.sql index cfc9dd9371..a3ffa65c48 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day -) subq_5 + subq_3.booking__ds__martian_day +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0_optimized.sql index fade916c75..ec04bb54d3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY - subq_8.martian_day + subq_6.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0.sql index f51b398753..bc330bc00c 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__ds__martian_day -) subq_10 + subq_7.listing__ds__martian_day +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index f36ac75d16..3b149b39b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_14.ds GROUP BY - subq_18.martian_day + subq_14.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0.sql index fae6ff992a..eb23de5d49 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 28f1b6995f..1ea0cb2615 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index 8d64ef3e48..ac9d44d80b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day -) subq_6 + subq_4.metric_time__martian_day +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 8c1f6de498..e5498b173a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index 32c775ba75..c0d7582135 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY - subq_13.listing__user__ds__martian_day -) subq_14 + subq_11.listing__user__ds__martian_day +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 4d3c50e9a2..71414f4240 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Databricks/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day - , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY - subq_26.martian_day + subq_22.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0.sql index 1704136793..8eb3bf50af 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 + subq_3.metric_time__martian_day + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , GEN_RANDOM_UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > subq_12.metric_time__day - MAKE_INTERVAL(days => 7) - ) + subq_8.metric_time__day > subq_11.metric_time__day - MAKE_INTERVAL(days => 7) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - subq_16.metric_time__martian_day - ) subq_17 + subq_14.metric_time__martian_day + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) -) subq_18 + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index f4a4d46e7e..7cf0facf82 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY - subq_21.martian_day - ) subq_24 + subq_18.martian_day + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > subq_31.metric_time__day - MAKE_INTERVAL(days => 7) + subq_25.metric_time__day > subq_28.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) -) subq_37 + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0.sql index 4d06c0910a..78536a0114 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day - ) subq_6 + subq_4.metric_time__martian_day + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , GEN_RANDOM_UUID() AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > subq_14.metric_time__day - MAKE_INTERVAL(days => 7) - ) + subq_10.metric_time__day > subq_13.metric_time__day - MAKE_INTERVAL(days => 7) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY - subq_18.metric_time__martian_day - ) subq_19 + subq_16.metric_time__martian_day + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) -) subq_20 + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index f9fae14d2b..b86ae8bd00 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > subq_35.metric_time__day - MAKE_INTERVAL(days => 7) + subq_29.metric_time__day > subq_32.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) -) subq_41 + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index d53fd83e78..f56bc259b5 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers , GEN_RANDOM_UUID() AS mf_internal_uuid 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > subq_14.metric_time__day - MAKE_INTERVAL(days => 7) + subq_10.metric_time__day > subq_13.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index 5a58de27e3..22c9b077d0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_26.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_24.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > subq_34.metric_time__day - MAKE_INTERVAL(days => 7) + subq_29.metric_time__day > subq_32.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0.sql index 3be1505330..57e51da490 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(months => 2) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY subq_6.metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 8001e6a3c5..8d627ad694 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,35 +9,30 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds - ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > subq_13.ds - MAKE_INTERVAL(months => 2) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds + ) AND ( + DATE_TRUNC('day', revenue_src_28000.created_at) > subq_13.ds - MAKE_INTERVAL(months => 2) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY - subq_15.martian_day - , subq_14.metric_time__day + subq_14.martian_day + , subq_13.ds ) subq_17 ) subq_19 GROUP BY diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0.sql index 5e1a1c349e..6951b18cc0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day - ) subq_5 - ) subq_6 + subq_3.booking__ds__martian_day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.booking__ds__martian_day - ) subq_12 - ) subq_13 + subq_9.booking__ds__martian_day + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) -) subq_14 + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 3bc3f746f5..d315d358a7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_14.ds GROUP BY - subq_17.martian_day -) subq_21 + subq_14.martian_day +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index bc46bbc2a8..3cf7bfb112 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - , subq_4.listing__ds__month -) subq_5 + subq_3.metric_time__martian_day + , subq_3.listing__ds__month +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 2f45574e41..091f68a2c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('month', created_at) AS listing__ds__month - , DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day + , DATE_TRUNC('month', created_at) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY - subq_8.martian_day - , subq_7.listing__ds__month + subq_6.martian_day + , subq_5.listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0.sql index 5059d9a939..0e9a6340b4 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 -) subq_6 + subq_3.metric_time__martian_day + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.metric_time__martian_day - ) subq_12 -) subq_13 + subq_9.metric_time__martian_day + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index e5b55102e9..ae8868ac3d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY - subq_16.martian_day -) subq_20 + subq_13.martian_day +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY - subq_23.martian_day -) subq_27 + subq_19.martian_day +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql index b3a966f4b5..ce8c276468 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week + , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month + , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter + , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , EXTRACT(isodow FROM subq_2.booking__ds__day) AS booking__ds__extract_dow + , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week - , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month - , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter - , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , EXTRACT(isodow FROM subq_2.booking__ds__day) AS booking__ds__extract_dow - , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - subq_2.booking__ds__day - MAKE_INTERVAL(days => 5) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + subq_2.booking__ds__day - MAKE_INTERVAL(days => 5) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY - subq_7.booking__ds__martian_day - ) subq_8 -) subq_9 + subq_6.booking__ds__martian_day + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0_optimized.sql index 7b54aaee93..1d4e27cb31 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - 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_28000 - ) subq_11 - ON - subq_13.ds - MAKE_INTERVAL(days => 5) = subq_11.booking__ds__day - ) subq_14 + DATE_TRUNC('day', ds) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + subq_12.ds - MAKE_INTERVAL(days => 5) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY - subq_15.martian_day -) subq_19 + subq_13.martian_day +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 7d74f7a93c..7fd92494d5 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + subq_2.metric_time__day - MAKE_INTERVAL(days => 5) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index b06f035335..66261a43aa 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - 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_28000 - ) subq_12 - ON - subq_14.ds - MAKE_INTERVAL(days => 5) = subq_12.metric_time__day - ) subq_15 + DATE_TRUNC('day', ds) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + subq_13.ds - MAKE_INTERVAL(days => 5) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0.sql index 5b7bb60efa..ad4f7f44b1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day -) subq_5 + subq_3.booking__ds__martian_day +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0_optimized.sql index fade916c75..ec04bb54d3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY - subq_8.martian_day + subq_6.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0.sql index 1998864955..82252cdf25 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__ds__martian_day -) subq_10 + subq_7.listing__ds__martian_day +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index f36ac75d16..3b149b39b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_14.ds GROUP BY - subq_18.martian_day + subq_14.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0.sql index d6197e5be1..1de9d4b282 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 28f1b6995f..1ea0cb2615 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index 07df220f23..410c6f8b17 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day -) subq_6 + subq_4.metric_time__martian_day +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 8c1f6de498..e5498b173a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index fb56a0ee0b..425a534ec2 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY - subq_13.listing__user__ds__martian_day -) subq_14 + subq_11.listing__user__ds__martian_day +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 4d3c50e9a2..71414f4240 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Postgres/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day - , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY - subq_26.martian_day + subq_22.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0.sql index 169c627090..34f4c04af3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 + subq_3.metric_time__martian_day + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.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_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) - ) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - subq_16.metric_time__martian_day - ) subq_17 + subq_14.metric_time__martian_day + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) -) subq_18 + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index b266858d57..654613309a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY - subq_21.martian_day - ) subq_24 + subq_18.martian_day + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > DATEADD(day, -7, subq_31.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) -) subq_37 + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0.sql index f87e0b4fe4..3ff7f74f2e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day - ) subq_6 + subq_4.metric_time__martian_day + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.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_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_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) - ) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY - subq_18.metric_time__martian_day - ) subq_19 + subq_16.metric_time__martian_day + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) -) subq_20 + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index b3a5f3d55c..3ef52f297e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > DATEADD(day, -7, subq_35.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) -) subq_41 + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index e1f1a23d74..aad4f74e6d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_19.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.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_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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index 8e334cfc14..e43d7fa3d5 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_26.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_24.visits), 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > DATEADD(day, -7, subq_34.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0.sql index 47cdbff139..d6394d42d6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > DATEADD(month, -2, subq_2.metric_time__day) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY subq_6.metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 6907f4775e..97db43cbe1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,35 +9,30 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds - ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds + ) AND ( + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY - subq_15.martian_day - , subq_14.metric_time__day + subq_14.martian_day + , subq_13.ds ) subq_17 ) subq_19 GROUP BY diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0.sql index 55d546bc60..047339cca7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day - ) subq_5 - ) subq_6 + subq_3.booking__ds__martian_day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.booking__ds__martian_day - ) subq_12 - ) subq_13 + subq_9.booking__ds__martian_day + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) -) subq_14 + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 3bc3f746f5..d315d358a7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_14.ds GROUP BY - subq_17.martian_day -) subq_21 + subq_14.martian_day +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index 3ee924bb0a..66fe555ba8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - , subq_4.listing__ds__month -) subq_5 + subq_3.metric_time__martian_day + , subq_3.listing__ds__month +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 2f45574e41..091f68a2c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('month', created_at) AS listing__ds__month - , DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day + , DATE_TRUNC('month', created_at) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY - subq_8.martian_day - , subq_7.listing__ds__month + subq_6.martian_day + , subq_5.listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0.sql index 56c5a25840..33e0021df0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 -) subq_6 + subq_3.metric_time__martian_day + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.metric_time__martian_day - ) subq_12 -) subq_13 + subq_9.metric_time__martian_day + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index e5b55102e9..ae8868ac3d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY - subq_16.martian_day -) subq_20 + subq_13.martian_day +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY - subq_23.martian_day -) subq_27 + subq_19.martian_day +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql index b812644b45..6145555ea9 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week + , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month + , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter + , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.booking__ds__day) = 0 THEN EXTRACT(dow FROM subq_2.booking__ds__day) + 7 ELSE EXTRACT(dow FROM subq_2.booking__ds__day) END AS booking__ds__extract_dow + , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week - , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month - , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter - , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM subq_2.booking__ds__day) = 0 THEN EXTRACT(dow FROM subq_2.booking__ds__day) + 7 ELSE EXTRACT(dow FROM subq_2.booking__ds__day) END AS booking__ds__extract_dow - , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY - subq_7.booking__ds__martian_day - ) subq_8 -) subq_9 + subq_6.booking__ds__martian_day + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0_optimized.sql index 0eeb6b2bc0..0be3ead6fd 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - 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_28000 - ) subq_11 - ON - DATEADD(day, -5, subq_13.ds) = subq_11.booking__ds__day - ) subq_14 + DATE_TRUNC('day', ds) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + DATEADD(day, -5, subq_12.ds) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY - subq_15.martian_day -) subq_19 + subq_13.martian_day +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 19e97f1475..f83f81e566 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index ed5c7dd88f..21e34e9859 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - 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_28000 - ) subq_12 - ON - DATEADD(day, -5, subq_14.ds) = subq_12.metric_time__day - ) subq_15 + DATE_TRUNC('day', ds) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + DATEADD(day, -5, subq_13.ds) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0.sql index 409ed92159..6f01995df0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day -) subq_5 + subq_3.booking__ds__martian_day +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0_optimized.sql index fade916c75..ec04bb54d3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY - subq_8.martian_day + subq_6.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0.sql index 633ea54c1d..2bf7695c9e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__ds__martian_day -) subq_10 + subq_7.listing__ds__martian_day +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index f36ac75d16..3b149b39b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_14.ds GROUP BY - subq_18.martian_day + subq_14.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0.sql index e453e1cb0c..14237537a2 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 28f1b6995f..1ea0cb2615 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index b85e660492..727d7e4821 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day -) subq_6 + subq_4.metric_time__martian_day +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 8c1f6de498..e5498b173a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index 0b30358d05..b640afd262 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY - subq_13.listing__user__ds__martian_day -) subq_14 + subq_11.listing__user__ds__martian_day +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 4d3c50e9a2..71414f4240 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Redshift/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day - , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY - subq_26.martian_day + subq_22.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0.sql index adbfe90840..7cadc04f82 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 + subq_3.metric_time__martian_day + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , UUID_STRING() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > DATEADD(day, -7, subq_12.metric_time__day) - ) + subq_8.metric_time__day > DATEADD(day, -7, subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - subq_16.metric_time__martian_day - ) subq_17 + subq_14.metric_time__martian_day + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) -) subq_18 + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index 3bf89f67bd..3667037821 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY - subq_21.martian_day - ) subq_24 + subq_18.martian_day + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > DATEADD(day, -7, subq_31.metric_time__day) + subq_25.metric_time__day > DATEADD(day, -7, subq_28.metric_time__day) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) -) subq_37 + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0.sql index b6c5a5d9b0..a405713651 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS DOUBLE) / CAST(NULLIF(subq_20.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day - ) subq_6 + subq_4.metric_time__martian_day + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers + , UUID_STRING() AS mf_internal_uuid + 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , UUID_STRING() AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) - ) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY - subq_18.metric_time__martian_day - ) subq_19 + subq_16.metric_time__martian_day + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) -) subq_20 + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index 3310c05a4d..3f18a22c30 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > DATEADD(day, -7, subq_35.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) -) subq_41 + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 8bdb235452..3200d08d20 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS DOUBLE) / CAST(NULLIF(subq_19.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers , UUID_STRING() AS mf_internal_uuid 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > DATEADD(day, -7, subq_14.metric_time__day) + subq_10.metric_time__day > DATEADD(day, -7, subq_13.metric_time__day) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index 90624604b9..7dd5cf633f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_26.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_24.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > DATEADD(day, -7, subq_34.metric_time__day) + subq_29.metric_time__day > DATEADD(day, -7, subq_32.metric_time__day) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0.sql index 12382af4f6..fc080d2b2b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > DATEADD(month, -2, subq_2.metric_time__day) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY subq_6.metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 6907f4775e..97db43cbe1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,35 +9,30 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds - ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds + ) AND ( + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY - subq_15.martian_day - , subq_14.metric_time__day + subq_14.martian_day + , subq_13.ds ) subq_17 ) subq_19 GROUP BY diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0.sql index 8ac011d264..8855dbdf75 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day - ) subq_5 - ) subq_6 + subq_3.booking__ds__martian_day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.booking__ds__martian_day - ) subq_12 - ) subq_13 + subq_9.booking__ds__martian_day + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) -) subq_14 + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 3bc3f746f5..d315d358a7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_14.ds GROUP BY - subq_17.martian_day -) subq_21 + subq_14.martian_day +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index 5b4c73f514..af6e1e066a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - , subq_4.listing__ds__month -) subq_5 + subq_3.metric_time__martian_day + , subq_3.listing__ds__month +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 2f45574e41..091f68a2c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('month', created_at) AS listing__ds__month - , DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day + , DATE_TRUNC('month', created_at) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY - subq_8.martian_day - , subq_7.listing__ds__month + subq_6.martian_day + , subq_5.listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0.sql index 471a38e071..8c14590c1d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 -) subq_6 + subq_3.metric_time__martian_day + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.metric_time__martian_day - ) subq_12 -) subq_13 + subq_9.metric_time__martian_day + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index e5b55102e9..ae8868ac3d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY - subq_16.martian_day -) subq_20 + subq_13.martian_day +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY - subq_23.martian_day -) subq_27 + subq_19.martian_day +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql index 3b66e7458f..33884df184 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week + , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month + , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter + , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM subq_2.booking__ds__day) AS booking__ds__extract_dow + , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week - , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month - , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter - , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM subq_2.booking__ds__day) AS booking__ds__extract_dow - , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.booking__ds__day) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY - subq_7.booking__ds__martian_day - ) subq_8 -) subq_9 + subq_6.booking__ds__martian_day + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0_optimized.sql index 0eeb6b2bc0..0be3ead6fd 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - 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_28000 - ) subq_11 - ON - DATEADD(day, -5, subq_13.ds) = subq_11.booking__ds__day - ) subq_14 + DATE_TRUNC('day', ds) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + DATEADD(day, -5, subq_12.ds) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY - subq_15.martian_day -) subq_19 + subq_13.martian_day +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 5eeec78066..1f100667aa 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATEADD(day, -5, subq_2.metric_time__day) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index ed5c7dd88f..21e34e9859 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - 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_28000 - ) subq_12 - ON - DATEADD(day, -5, subq_14.ds) = subq_12.metric_time__day - ) subq_15 + DATE_TRUNC('day', ds) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + DATEADD(day, -5, subq_13.ds) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0.sql index 318b1727c4..f19923702d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day -) subq_5 + subq_3.booking__ds__martian_day +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0_optimized.sql index fade916c75..ec04bb54d3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY - subq_8.martian_day + subq_6.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0.sql index 04048d1285..499c49a210 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__ds__martian_day -) subq_10 + subq_7.listing__ds__martian_day +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index f36ac75d16..3b149b39b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_14.ds GROUP BY - subq_18.martian_day + subq_14.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0.sql index 0f30146281..cd913b6941 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 28f1b6995f..1ea0cb2615 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index 898e5a80a8..9da445f83f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day -) subq_6 + subq_4.metric_time__martian_day +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 8c1f6de498..e5498b173a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index 0b58d7018f..b2e1ae3c6a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY - subq_13.listing__user__ds__martian_day -) subq_14 + subq_11.listing__user__ds__martian_day +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 4d3c50e9a2..71414f4240 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Snowflake/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day - , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY - subq_26.martian_day + subq_22.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0.sql index 91b7372723..48293955ee 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0.sql @@ -1,449 +1,437 @@ -- Compute Metrics via Expressions SELECT - subq_18.metric_time__martian_day - , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_16.metric_time__martian_day + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_5.visits) AS visits - , MAX(subq_17.buys) AS buys + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_4.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.visits) AS visits + subq_3.metric_time__martian_day + , SUM(subq_3.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.visits + subq_2.metric_time__martian_day + , subq_2.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 + subq_3.metric_time__martian_day + ) subq_4 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_16.metric_time__martian_day - , SUM(subq_16.buys) AS buys + subq_14.metric_time__martian_day + , SUM(subq_14.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_15.metric_time__martian_day - , subq_15.buys + subq_13.metric_time__martian_day + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_14.metric_time__martian_day - , subq_14.buys + subq_12.metric_time__martian_day + , subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_13.metric_time__martian_day - , subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__martian_day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__martian_day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_7.metric_time__martian_day + , subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__martian_day - , subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_5.ds__day AS ds__day + , subq_5.ds__week AS ds__week + , subq_5.ds__month AS ds__month + , subq_5.ds__quarter AS ds__quarter + , subq_5.ds__year AS ds__year + , subq_5.ds__extract_year AS ds__extract_year + , subq_5.ds__extract_quarter AS ds__extract_quarter + , subq_5.ds__extract_month AS ds__extract_month + , subq_5.ds__extract_day AS ds__extract_day + , subq_5.ds__extract_dow AS ds__extract_dow + , subq_5.ds__extract_doy AS ds__extract_doy + , subq_5.visit__ds__day AS visit__ds__day + , subq_5.visit__ds__week AS visit__ds__week + , subq_5.visit__ds__month AS visit__ds__month + , subq_5.visit__ds__quarter AS visit__ds__quarter + , subq_5.visit__ds__year AS visit__ds__year + , subq_5.visit__ds__extract_year AS visit__ds__extract_year + , subq_5.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_5.visit__ds__extract_month AS visit__ds__extract_month + , subq_5.visit__ds__extract_day AS visit__ds__extract_day + , subq_5.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_5.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_5.ds__day AS metric_time__day + , subq_5.ds__week AS metric_time__week + , subq_5.ds__month AS metric_time__month + , subq_5.ds__quarter AS metric_time__quarter + , subq_5.ds__year AS metric_time__year + , subq_5.ds__extract_year AS metric_time__extract_year + , subq_5.ds__extract_quarter AS metric_time__extract_quarter + , subq_5.ds__extract_month AS metric_time__extract_month + , subq_5.ds__extract_day AS metric_time__extract_day + , subq_5.ds__extract_dow AS metric_time__extract_dow + , subq_5.ds__extract_doy AS metric_time__extract_doy + , subq_5.user AS user + , subq_5.session AS session + , subq_5.visit__user AS visit__user + , subq_5.visit__session AS visit__session + , subq_5.referrer_id AS referrer_id + , subq_5.visit__referrer_id AS visit__referrer_id + , subq_5.visits AS visits + , subq_5.visitors AS visitors + , subq_6.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_6.visit__ds__week AS visit__ds__week - , subq_6.visit__ds__month AS visit__ds__month - , subq_6.visit__ds__quarter AS visit__ds__quarter - , subq_6.visit__ds__year AS visit__ds__year - , subq_6.visit__ds__extract_year AS visit__ds__extract_year - , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_6.visit__ds__extract_month AS visit__ds__extract_month - , subq_6.visit__ds__extract_day AS visit__ds__extract_day - , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_6.ds__day AS metric_time__day - , subq_6.ds__week AS metric_time__week - , subq_6.ds__month AS metric_time__month - , subq_6.ds__quarter AS metric_time__quarter - , subq_6.ds__year AS metric_time__year - , subq_6.ds__extract_year AS metric_time__extract_year - , subq_6.ds__extract_quarter AS metric_time__extract_quarter - , subq_6.ds__extract_month AS metric_time__extract_month - , subq_6.ds__extract_day AS metric_time__extract_day - , subq_6.ds__extract_dow AS metric_time__extract_dow - , subq_6.ds__extract_doy AS metric_time__extract_doy - , subq_6.user AS user - , subq_6.session AS session - , subq_6.visit__user AS visit__user - , subq_6.visit__session AS visit__session - , subq_6.referrer_id AS referrer_id - , subq_6.visit__referrer_id AS visit__referrer_id - , subq_6.visits AS visits - , subq_6.visitors AS visitors - , subq_7.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_6 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 - ON - subq_6.ds__day = subq_7.ds - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_5 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_6 + ON + subq_5.ds__day = subq_6.ds + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , uuid() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , uuid() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( ( - subq_9.user = subq_12.user + subq_8.metric_time__day <= subq_11.metric_time__day ) AND ( - ( - subq_9.metric_time__day <= subq_12.metric_time__day - ) AND ( - subq_9.metric_time__day > DATE_ADD('day', -7, subq_12.metric_time__day) - ) + subq_8.metric_time__day > DATE_ADD('day', -7, subq_11.metric_time__day) ) - ) subq_13 - ) subq_14 - ) subq_15 - ) subq_16 + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - subq_16.metric_time__martian_day - ) subq_17 + subq_14.metric_time__martian_day + ) subq_15 ON - subq_5.metric_time__martian_day = subq_17.metric_time__martian_day + subq_4.metric_time__martian_day = subq_15.metric_time__martian_day GROUP BY - COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) -) subq_18 + COALESCE(subq_4.metric_time__martian_day, subq_15.metric_time__martian_day) +) subq_16 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0_optimized.sql index 219dbfcb5e..8d93c807d4 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity__plan0_optimized.sql @@ -5,36 +5,34 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_24.visits) AS visits - , MAX(subq_36.buys) AS buys + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_21.visits) AS visits + , MAX(subq_32.buys) AS buys FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__martian_day'] -- Aggregate Measures SELECT - subq_21.martian_day AS metric_time__martian_day - , SUM(subq_20.visits) AS visits + subq_18.martian_day AS metric_time__martian_day + , SUM(subq_17.visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_20 + ) subq_17 LEFT OUTER JOIN - ***************************.mf_time_spine subq_21 + ***************************.mf_time_spine subq_18 ON - subq_20.metric_time__day = subq_21.ds + subq_17.ds__day = subq_18.ds GROUP BY - subq_21.martian_day - ) subq_24 + subq_18.martian_day + ) subq_21 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -42,49 +40,49 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_28.visits) OVER ( + FIRST_VALUE(subq_25.visits) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_28.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_25.metric_time__martian_day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_28.metric_time__day) OVER ( + , FIRST_VALUE(subq_25.metric_time__day) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_28.user) OVER ( + , FIRST_VALUE(subq_25.user) OVER ( PARTITION BY - subq_31.user - , subq_31.metric_time__day - , subq_31.mf_internal_uuid - ORDER BY subq_28.metric_time__day DESC + subq_28.user + , subq_28.metric_time__day + , subq_28.mf_internal_uuid + ORDER BY subq_25.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_31.mf_internal_uuid AS mf_internal_uuid - , subq_31.buys AS buys + , subq_28.mf_internal_uuid AS mf_internal_uuid + , subq_28.buys AS buys FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_26.martian_day AS metric_time__martian_day - , subq_25.ds__day AS metric_time__day - , subq_25.user AS user - , subq_25.visits AS visits + subq_23.martian_day AS metric_time__martian_day + , subq_22.ds__day AS metric_time__day + , subq_22.user AS user + , subq_22.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -92,12 +90,12 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_25 + ) subq_22 LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_23 ON - subq_25.ds__day = subq_26.ds - ) subq_28 + subq_22.ds__day = subq_23.ds + ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -108,23 +106,23 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_31 + ) subq_28 ON ( - subq_28.user = subq_31.user + subq_25.user = subq_28.user ) AND ( ( - subq_28.metric_time__day <= subq_31.metric_time__day + subq_25.metric_time__day <= subq_28.metric_time__day ) AND ( - subq_28.metric_time__day > DATE_ADD('day', -7, subq_31.metric_time__day) + subq_25.metric_time__day > DATE_ADD('day', -7, subq_28.metric_time__day) ) ) - ) subq_32 + ) subq_29 GROUP BY metric_time__martian_day - ) subq_36 + ) subq_32 ON - subq_24.metric_time__martian_day = subq_36.metric_time__martian_day + subq_21.metric_time__martian_day = subq_32.metric_time__martian_day GROUP BY - COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) -) subq_37 + COALESCE(subq_21.metric_time__martian_day, subq_32.metric_time__martian_day) +) subq_33 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0.sql index 6b1728611a..0ab9dc8fdf 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0.sql @@ -1,504 +1,531 @@ -- Compute Metrics via Expressions SELECT - subq_20.metric_time__martian_day - , CAST(subq_20.buys AS DOUBLE) / CAST(NULLIF(subq_20.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_18.metric_time__martian_day + , CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.visits) AS visits - , MAX(subq_19.buys) AS buys + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.visits) AS visits + subq_4.metric_time__martian_day + , SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.visits + subq_3.metric_time__martian_day + , subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day - ) subq_6 + subq_4.metric_time__martian_day + ) subq_5 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_18.metric_time__martian_day - , SUM(subq_18.buys) AS buys + subq_16.metric_time__martian_day + , SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'metric_time__martian_day'] SELECT - subq_17.metric_time__martian_day - , subq_17.buys + subq_15.metric_time__martian_day + , subq_15.buys FROM ( - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] + -- Find conversions for user within the range of 7 day SELECT - subq_16.metric_time__martian_day - , subq_16.buys + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( - -- Find conversions for user within the range of 7 day - SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_10.visits) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__martian_day + , FIRST_VALUE(subq_10.metric_time__day) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_10.user) OVER ( + PARTITION BY + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( - PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + SELECT + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] + -- Constrain Output with WHERE SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'ds' + -- Join to Custom Granularity Dataset SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + 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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' - -- Join to Custom Granularity Dataset + -- Read Elements From Semantic Model 'visits_source' SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_day - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 - ON - subq_7.ds__day = subq_8.ds - ) subq_9 - WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + LEFT OUTER JOIN + ***************************.mf_time_spine subq_7 + ON + subq_6.ds__day = subq_7.ds + ) subq_8 + WHERE metric_time__martian_day = '2020-01-01' + ) subq_9 + ) subq_10 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers + , uuid() AS mf_internal_uuid + 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers - , uuid() AS mf_internal_uuid + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_12 - ) subq_13 - ) subq_14 - ON + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_11 + ) subq_12 + ) subq_13 + ON + ( + subq_10.user = subq_13.user + ) AND ( ( - subq_11.user = subq_14.user + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - ( - subq_11.metric_time__day <= subq_14.metric_time__day - ) AND ( - subq_11.metric_time__day > DATE_ADD('day', -7, subq_14.metric_time__day) - ) + subq_10.metric_time__day > DATE_ADD('day', -7, subq_13.metric_time__day) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 + ) + ) subq_14 + ) subq_15 + ) subq_16 GROUP BY - subq_18.metric_time__martian_day - ) subq_19 + subq_16.metric_time__martian_day + ) subq_17 ON - subq_6.metric_time__martian_day = subq_19.metric_time__martian_day + subq_5.metric_time__martian_day = subq_17.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_19.metric_time__martian_day) -) subq_20 + COALESCE(subq_5.metric_time__martian_day, subq_17.metric_time__martian_day) +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql index 0667a186d8..2b4715c927 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_27.visits) AS visits - , MAX(subq_40.buys) AS buys + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_24.visits) AS visits + , MAX(subq_36.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__martian_day'] @@ -16,32 +16,30 @@ FROM ( metric_time__martian_day , SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_22.visits AS visits - , subq_23.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_20 ON - subq_22.metric_time__day = subq_23.ds - ) subq_24 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__martian_day'] - -- Pass Only Elements: ['buys', 'metric_time__martian_day'] -- Aggregate Measures SELECT metric_time__martian_day @@ -49,56 +47,56 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_32.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_32.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_32.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_32.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_35.user - , subq_35.metric_time__day - , subq_35.mf_internal_uuid - ORDER BY subq_32.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_35.mf_internal_uuid AS mf_internal_uuid - , subq_35.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_30.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_28.ds__day AS metric_time__day - , subq_28.user AS user - , subq_28.visits AS visits - , subq_29.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -106,14 +104,14 @@ FROM ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_28 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_29 + ***************************.mf_time_spine subq_26 ON - subq_28.ds__day = subq_29.ds - ) subq_30 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_32 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -124,23 +122,23 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_35 + ) subq_32 ON ( - subq_32.user = subq_35.user + subq_29.user = subq_32.user ) AND ( ( - subq_32.metric_time__day <= subq_35.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_32.metric_time__day > DATE_ADD('day', -7, subq_35.metric_time__day) + subq_29.metric_time__day > DATE_ADD('day', -7, subq_32.metric_time__day) ) ) - ) subq_36 + ) subq_33 GROUP BY metric_time__martian_day - ) subq_40 + ) subq_36 ON - subq_27.metric_time__martian_day = subq_40.metric_time__martian_day + subq_24.metric_time__martian_day = subq_36.metric_time__martian_day GROUP BY - COALESCE(subq_27.metric_time__martian_day, subq_40.metric_time__martian_day) -) subq_41 + COALESCE(subq_24.metric_time__martian_day, subq_36.metric_time__martian_day) +) subq_37 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 97762bf5ac..e0a7e94c56 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,272 +1,305 @@ -- Compute Metrics via Expressions SELECT - CAST(subq_19.buys AS DOUBLE) / CAST(NULLIF(subq_19.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(subq_18.buys AS DOUBLE) / CAST(NULLIF(subq_18.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_6.visits) AS visits - , MAX(subq_18.buys) AS buys + MAX(subq_5.visits) AS visits + , MAX(subq_17.buys) AS buys FROM ( -- Aggregate Measures SELECT - SUM(subq_5.visits) AS visits + SUM(subq_4.visits) AS visits FROM ( -- Pass Only Elements: ['visits',] SELECT - subq_4.visits + subq_3.visits FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.visits + subq_2.metric_time__martian_day + , 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.visits AS visits - , subq_2.martian_day AS metric_time__martian_day + 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.visit__ds__day AS visit__ds__day + , subq_0.visit__ds__week AS visit__ds__week + , subq_0.visit__ds__month AS visit__ds__month + , subq_0.visit__ds__quarter AS visit__ds__quarter + , subq_0.visit__ds__year AS visit__ds__year + , subq_0.visit__ds__extract_year AS visit__ds__extract_year + , subq_0.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_0.visit__ds__extract_month AS visit__ds__extract_month + , subq_0.visit__ds__extract_day AS visit__ds__extract_day + , subq_0.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_0.visit__ds__extract_doy AS 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 AS user + , subq_0.session AS session + , subq_0.visit__user AS visit__user + , subq_0.visit__session AS visit__session + , subq_0.referrer_id AS referrer_id + , subq_0.visit__referrer_id AS visit__referrer_id + , subq_0.visits AS visits + , subq_0.visitors AS visitors + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 + 1 AS visits + , 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_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 - ) subq_6 + ) subq_3 + ) subq_4 + ) subq_5 CROSS JOIN ( -- Aggregate Measures SELECT - SUM(subq_17.buys) AS buys + SUM(subq_16.buys) AS buys FROM ( -- Pass Only Elements: ['buys',] SELECT - subq_16.buys + subq_15.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_15.metric_time__martian_day - , subq_15.metric_time__day - , subq_15.user - , subq_15.buys - , subq_15.visits + subq_14.metric_time__martian_day + , subq_14.metric_time__day + , subq_14.user + , subq_14.buys + , subq_14.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_11.visits) OVER ( + FIRST_VALUE(subq_10.visits) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_11.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_10.metric_time__martian_day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_11.metric_time__day) OVER ( + , FIRST_VALUE(subq_10.metric_time__day) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_11.user) OVER ( + , FIRST_VALUE(subq_10.user) OVER ( PARTITION BY - subq_14.user - , subq_14.metric_time__day - , subq_14.mf_internal_uuid - ORDER BY subq_11.metric_time__day DESC + subq_13.user + , subq_13.metric_time__day + , subq_13.mf_internal_uuid + ORDER BY subq_10.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_14.mf_internal_uuid AS mf_internal_uuid - , subq_14.buys AS buys + , subq_13.mf_internal_uuid AS mf_internal_uuid + , subq_13.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT - subq_10.metric_time__martian_day - , subq_10.metric_time__day - , subq_10.user - , subq_10.visits + subq_9.metric_time__martian_day + , subq_9.metric_time__day + , subq_9.user + , subq_9.visits FROM ( -- Constrain Output with WHERE SELECT - subq_9.metric_time__martian_day - , subq_9.ds__day - , subq_9.ds__week - , subq_9.ds__month - , subq_9.ds__quarter - , subq_9.ds__year - , subq_9.ds__extract_year - , subq_9.ds__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.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.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 + subq_8.metric_time__martian_day + , 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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__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 + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - 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.visit__ds__day AS visit__ds__day - , subq_7.visit__ds__week AS visit__ds__week - , subq_7.visit__ds__month AS visit__ds__month - , subq_7.visit__ds__quarter AS visit__ds__quarter - , subq_7.visit__ds__year AS visit__ds__year - , subq_7.visit__ds__extract_year AS visit__ds__extract_year - , subq_7.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_7.visit__ds__extract_month AS visit__ds__extract_month - , subq_7.visit__ds__extract_day AS visit__ds__extract_day - , subq_7.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_7.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user AS user - , subq_7.session AS session - , subq_7.visit__user AS visit__user - , subq_7.visit__session AS visit__session - , subq_7.referrer_id AS referrer_id - , subq_7.visit__referrer_id AS visit__referrer_id - , subq_7.visits AS visits - , subq_7.visitors AS visitors - , subq_8.martian_day AS metric_time__martian_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.visit__ds__day AS visit__ds__day + , subq_6.visit__ds__week AS visit__ds__week + , subq_6.visit__ds__month AS visit__ds__month + , subq_6.visit__ds__quarter AS visit__ds__quarter + , subq_6.visit__ds__year AS visit__ds__year + , subq_6.visit__ds__extract_year AS visit__ds__extract_year + , subq_6.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_6.visit__ds__extract_month AS visit__ds__extract_month + , subq_6.visit__ds__extract_day AS visit__ds__extract_day + , subq_6.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_6.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user AS user + , subq_6.session AS session + , subq_6.visit__user AS visit__user + , subq_6.visit__session AS visit__session + , subq_6.referrer_id AS referrer_id + , subq_6.visit__referrer_id AS visit__referrer_id + , subq_6.visits AS visits + , subq_6.visitors AS visitors + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -301,124 +334,124 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_7 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_7 ON - subq_7.ds__day = subq_8.ds - ) subq_9 + subq_6.ds__day = subq_7.ds + ) subq_8 WHERE metric_time__martian_day = '2020-01-01' - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 INNER JOIN ( -- Add column with generated UUID 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.ds_month__month - , subq_13.ds_month__quarter - , subq_13.ds_month__year - , subq_13.ds_month__extract_year - , subq_13.ds_month__extract_quarter - , subq_13.ds_month__extract_month - , subq_13.buy__ds__day - , subq_13.buy__ds__week - , subq_13.buy__ds__month - , subq_13.buy__ds__quarter - , subq_13.buy__ds__year - , subq_13.buy__ds__extract_year - , subq_13.buy__ds__extract_quarter - , subq_13.buy__ds__extract_month - , subq_13.buy__ds__extract_day - , subq_13.buy__ds__extract_dow - , subq_13.buy__ds__extract_doy - , subq_13.buy__ds_month__month - , subq_13.buy__ds_month__quarter - , subq_13.buy__ds_month__year - , subq_13.buy__ds_month__extract_year - , subq_13.buy__ds_month__extract_quarter - , subq_13.buy__ds_month__extract_month - , subq_13.metric_time__day - , subq_13.metric_time__week - , subq_13.metric_time__month - , subq_13.metric_time__quarter - , subq_13.metric_time__year - , subq_13.metric_time__extract_year - , subq_13.metric_time__extract_quarter - , subq_13.metric_time__extract_month - , subq_13.metric_time__extract_day - , subq_13.metric_time__extract_dow - , subq_13.metric_time__extract_doy - , subq_13.user - , subq_13.session_id - , subq_13.buy__user - , subq_13.buy__session_id - , subq_13.buys - , subq_13.buyers + 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_month__month + , subq_12.ds_month__quarter + , subq_12.ds_month__year + , subq_12.ds_month__extract_year + , subq_12.ds_month__extract_quarter + , subq_12.ds_month__extract_month + , subq_12.buy__ds__day + , subq_12.buy__ds__week + , subq_12.buy__ds__month + , subq_12.buy__ds__quarter + , subq_12.buy__ds__year + , subq_12.buy__ds__extract_year + , subq_12.buy__ds__extract_quarter + , subq_12.buy__ds__extract_month + , subq_12.buy__ds__extract_day + , subq_12.buy__ds__extract_dow + , subq_12.buy__ds__extract_doy + , subq_12.buy__ds_month__month + , subq_12.buy__ds_month__quarter + , subq_12.buy__ds_month__year + , subq_12.buy__ds_month__extract_year + , subq_12.buy__ds_month__extract_quarter + , subq_12.buy__ds_month__extract_month + , 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.session_id + , subq_12.buy__user + , subq_12.buy__session_id + , subq_12.buys + , subq_12.buyers , uuid() AS mf_internal_uuid 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_month__month - , subq_12.ds_month__quarter - , subq_12.ds_month__year - , subq_12.ds_month__extract_year - , subq_12.ds_month__extract_quarter - , subq_12.ds_month__extract_month - , subq_12.buy__ds__day - , subq_12.buy__ds__week - , subq_12.buy__ds__month - , subq_12.buy__ds__quarter - , subq_12.buy__ds__year - , subq_12.buy__ds__extract_year - , subq_12.buy__ds__extract_quarter - , subq_12.buy__ds__extract_month - , subq_12.buy__ds__extract_day - , subq_12.buy__ds__extract_dow - , subq_12.buy__ds__extract_doy - , subq_12.buy__ds_month__month - , subq_12.buy__ds_month__quarter - , subq_12.buy__ds_month__year - , subq_12.buy__ds_month__extract_year - , subq_12.buy__ds_month__extract_quarter - , subq_12.buy__ds_month__extract_month - , 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.user - , subq_12.session_id - , subq_12.buy__user - , subq_12.buy__session_id - , subq_12.buys - , subq_12.buyers + subq_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.ds_month__month + , subq_11.ds_month__quarter + , subq_11.ds_month__year + , subq_11.ds_month__extract_year + , subq_11.ds_month__extract_quarter + , subq_11.ds_month__extract_month + , subq_11.buy__ds__day + , subq_11.buy__ds__week + , subq_11.buy__ds__month + , subq_11.buy__ds__quarter + , subq_11.buy__ds__year + , subq_11.buy__ds__extract_year + , subq_11.buy__ds__extract_quarter + , subq_11.buy__ds__extract_month + , subq_11.buy__ds__extract_day + , subq_11.buy__ds__extract_dow + , subq_11.buy__ds__extract_doy + , subq_11.buy__ds_month__month + , subq_11.buy__ds_month__quarter + , subq_11.buy__ds_month__year + , subq_11.buy__ds_month__extract_year + , subq_11.buy__ds_month__extract_quarter + , subq_11.buy__ds_month__extract_month + , 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.session_id + , subq_11.buy__user + , subq_11.buy__session_id + , subq_11.buys + , subq_11.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -464,21 +497,21 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 + ) subq_13 ON ( - subq_11.user = subq_14.user + subq_10.user = subq_13.user ) AND ( ( - subq_11.metric_time__day <= subq_14.metric_time__day + subq_10.metric_time__day <= subq_13.metric_time__day ) AND ( - subq_11.metric_time__day > DATE_ADD('day', -7, subq_14.metric_time__day) + subq_10.metric_time__day > DATE_ADD('day', -7, subq_13.metric_time__day) ) ) - ) subq_15 - ) subq_16 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_14 + ) subq_15 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index 34ebe380a7..11cb2ddfd0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_conversion_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Aggregated Outputs -- Compute Metrics via Expressions SELECT - CAST(MAX(subq_38.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_26.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + CAST(MAX(subq_36.buys) AS DOUBLE) / CAST(NULLIF(MAX(subq_24.visits), 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits',] @@ -9,26 +9,25 @@ FROM ( SELECT SUM(visits) AS visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_21.visits AS visits - , subq_22.martian_day AS metric_time__martian_day + subq_19.visits AS visits + , subq_20.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS visits + 1 AS visits + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_visits visits_source_src_28000 - ) subq_21 + ) subq_19 LEFT OUTER JOIN - ***************************.mf_time_spine subq_22 + ***************************.mf_time_spine subq_20 ON - subq_21.metric_time__day = subq_22.ds - ) subq_23 + subq_19.ds__day = subq_20.ds + ) subq_21 WHERE metric_time__martian_day = '2020-01-01' -) subq_26 +) subq_24 CROSS JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys',] @@ -38,56 +37,56 @@ CROSS JOIN ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_31.visits) OVER ( + FIRST_VALUE(subq_29.visits) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_31.metric_time__martian_day) OVER ( + , FIRST_VALUE(subq_29.metric_time__martian_day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__martian_day - , FIRST_VALUE(subq_31.metric_time__day) OVER ( + , FIRST_VALUE(subq_29.metric_time__day) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_31.user) OVER ( + , FIRST_VALUE(subq_29.user) OVER ( PARTITION BY - subq_34.user - , subq_34.metric_time__day - , subq_34.mf_internal_uuid - ORDER BY subq_31.metric_time__day DESC + subq_32.user + , subq_32.metric_time__day + , subq_32.mf_internal_uuid + ORDER BY subq_29.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_34.mf_internal_uuid AS mf_internal_uuid - , subq_34.buys AS buys + , subq_32.mf_internal_uuid AS mf_internal_uuid + , subq_32.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'metric_time__day', 'metric_time__martian_day', 'user'] SELECT metric_time__martian_day , metric_time__day - , subq_29.user + , subq_27.user , visits FROM ( -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_27.ds__day AS metric_time__day - , subq_27.user AS user - , subq_27.visits AS visits - , subq_28.martian_day AS metric_time__martian_day + subq_25.ds__day AS metric_time__day + , subq_25.user AS user + , subq_25.visits AS visits + , subq_26.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -95,14 +94,14 @@ CROSS JOIN ( , DATE_TRUNC('day', ds) AS ds__day , user_id AS user FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_25 LEFT OUTER JOIN - ***************************.mf_time_spine subq_28 + ***************************.mf_time_spine subq_26 ON - subq_27.ds__day = subq_28.ds - ) subq_29 + subq_25.ds__day = subq_26.ds + ) subq_27 WHERE metric_time__martian_day = '2020-01-01' - ) subq_31 + ) subq_29 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -113,16 +112,16 @@ CROSS JOIN ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_34 + ) subq_32 ON ( - subq_31.user = subq_34.user + subq_29.user = subq_32.user ) AND ( ( - subq_31.metric_time__day <= subq_34.metric_time__day + subq_29.metric_time__day <= subq_32.metric_time__day ) AND ( - subq_31.metric_time__day > DATE_ADD('day', -7, subq_34.metric_time__day) + subq_29.metric_time__day > DATE_ADD('day', -7, subq_32.metric_time__day) ) ) - ) subq_35 -) subq_38 + ) subq_33 +) subq_36 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0.sql index 535df75a0b..a18fbb1aec 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0.sql @@ -20,14 +20,14 @@ FROM ( , subq_6.metric_time__day , SUM(subq_6.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] - -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.txn_revenue AS txn_revenue - , subq_5.martian_day AS metric_time__martian_day + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.txn_revenue FROM ( -- Join Self Over Time Range + -- Join to Custom Granularity Dataset SELECT subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day @@ -65,6 +65,7 @@ FROM ( , subq_1.user AS user , subq_1.revenue_instance__user AS revenue_instance__user , subq_1.txn_revenue AS txn_revenue + , subq_4.martian_day AS metric_time__martian_day FROM ( -- Time Spine SELECT @@ -147,11 +148,11 @@ FROM ( ) AND ( subq_1.metric_time__day > DATE_ADD('month', -2, subq_2.metric_time__day) ) - ) subq_4 - LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 - ON - subq_4.metric_time__day = subq_5.ds + LEFT OUTER JOIN + ***************************.mf_time_spine subq_4 + ON + subq_2.metric_time__day = subq_4.ds + ) subq_5 ) subq_6 GROUP BY subq_6.metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql index 4241dea8c8..b07fb4f0ad 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_cumulative_metric_with_custom_granularity__plan0_optimized.sql @@ -9,35 +9,30 @@ FROM ( metric_time__martian_day , AVG(txn_revenue) OVER (PARTITION BY metric_time__martian_day) AS trailing_2_months_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__day', 'metric_time__day'] + -- Join Self Over Time Range -- Join to Custom Granularity Dataset + -- Pass Only Elements: ['txn_revenue', 'metric_time__martian_day', 'metric_time__day'] -- Aggregate Measures SELECT - subq_15.martian_day AS metric_time__martian_day - , subq_14.metric_time__day AS metric_time__day - , SUM(subq_14.txn_revenue) AS txn_revenue - FROM ( - -- Join Self Over Time Range - SELECT - subq_13.ds AS metric_time__day - , revenue_src_28000.revenue AS txn_revenue - FROM ***************************.mf_time_spine subq_13 - INNER JOIN - ***************************.fct_revenue revenue_src_28000 - ON - ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds - ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATE_ADD('month', -2, subq_13.ds) - ) - ) subq_14 + subq_14.martian_day AS metric_time__martian_day + , subq_13.ds AS metric_time__day + , SUM(revenue_src_28000.revenue) AS txn_revenue + FROM ***************************.mf_time_spine subq_13 + INNER JOIN + ***************************.fct_revenue revenue_src_28000 + ON + ( + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds + ) AND ( + DATE_TRUNC('day', revenue_src_28000.created_at) > DATE_ADD('month', -2, subq_13.ds) + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_14 ON - subq_14.metric_time__day = subq_15.ds + subq_13.ds = subq_14.ds GROUP BY - subq_15.martian_day - , subq_14.metric_time__day + subq_14.martian_day + , subq_13.ds ) subq_17 ) subq_19 GROUP BY diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0.sql index 3ad0563bda..f726fb8f46 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0.sql @@ -1,469 +1,457 @@ -- Compute Metrics via Expressions SELECT - subq_14.booking__ds__martian_day + subq_12.booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) AS booking__ds__martian_day - , MAX(subq_6.booking_value) AS booking_value - , MAX(subq_13.bookers) AS bookers + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) AS booking__ds__martian_day + , MAX(subq_5.booking_value) AS booking_value + , MAX(subq_11.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.booking_value + subq_4.booking__ds__martian_day + , subq_4.booking_value FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.booking_value) AS booking_value + subq_3.booking__ds__martian_day + , SUM(subq_3.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.booking_value + subq_2.booking__ds__martian_day + , subq_2.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.booking_value AS booking_value - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day - ) subq_5 - ) subq_6 + subq_3.booking__ds__martian_day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.booking__ds__martian_day - , subq_12.bookers + subq_10.booking__ds__martian_day + , subq_10.bookers FROM ( -- Aggregate Measures SELECT - subq_11.booking__ds__martian_day - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.booking__ds__martian_day + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'booking__ds__martian_day'] SELECT - subq_10.booking__ds__martian_day - , subq_10.bookers + subq_8.booking__ds__martian_day + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.booking__ds__day AS booking__ds__day - , subq_8.bookers AS bookers - , subq_9.martian_day AS booking__ds__martian_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.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 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_7.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.booking__ds__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.booking__ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.booking__ds__martian_day - ) subq_12 - ) subq_13 + subq_9.booking__ds__martian_day + ) subq_10 + ) subq_11 ON - subq_6.booking__ds__martian_day = subq_13.booking__ds__martian_day + subq_5.booking__ds__martian_day = subq_11.booking__ds__martian_day GROUP BY - COALESCE(subq_6.booking__ds__martian_day, subq_13.booking__ds__martian_day) -) subq_14 + COALESCE(subq_5.booking__ds__martian_day, subq_11.booking__ds__martian_day) +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0_optimized.sql index 3bc3f746f5..d315d358a7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_derived_metric_with_custom_granularity__plan0_optimized.sql @@ -3,20 +3,20 @@ SELECT booking__ds__martian_day , booking_value * 0.05 / bookers AS booking_fees_per_booker FROM ( - -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['booking_value', 'bookers', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.martian_day AS booking__ds__martian_day + subq_14.martian_day AS booking__ds__martian_day , SUM(bookings_source_src_28000.booking_value) AS booking_value , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 LEFT OUTER JOIN - ***************************.mf_time_spine subq_17 + ***************************.mf_time_spine subq_14 ON - DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) = subq_14.ds GROUP BY - subq_17.martian_day -) subq_21 + subq_14.martian_day +) subq_18 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql index 090f38a141..84f9aa202b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0.sql @@ -1,167 +1,160 @@ -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.listing__ds__month - , subq_5.listings + subq_4.metric_time__martian_day + , subq_4.listing__ds__month + , subq_4.listings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , subq_4.listing__ds__month - , SUM(subq_4.listings) AS listings + subq_3.metric_time__martian_day + , subq_3.listing__ds__month + , SUM(subq_3.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] SELECT - subq_3.metric_time__martian_day - , subq_3.listing__ds__month - , subq_3.listings + subq_2.metric_time__martian_day + , subq_2.listing__ds__month + , subq_2.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.listing__ds__month AS listing__ds__month - , subq_1.metric_time__day AS metric_time__day - , subq_1.listings AS listings - , subq_2.martian_day AS metric_time__martian_day + subq_0.ds__day AS ds__day + , subq_0.ds__week AS ds__week + , subq_0.ds__month AS ds__month + , subq_0.ds__quarter AS ds__quarter + , subq_0.ds__year AS ds__year + , subq_0.ds__extract_year AS ds__extract_year + , subq_0.ds__extract_quarter AS ds__extract_quarter + , subq_0.ds__extract_month AS ds__extract_month + , subq_0.ds__extract_day AS ds__extract_day + , subq_0.ds__extract_dow AS ds__extract_dow + , subq_0.ds__extract_doy AS ds__extract_doy + , subq_0.created_at__day AS created_at__day + , subq_0.created_at__week AS created_at__week + , subq_0.created_at__month AS created_at__month + , subq_0.created_at__quarter AS created_at__quarter + , subq_0.created_at__year AS created_at__year + , subq_0.created_at__extract_year AS created_at__extract_year + , subq_0.created_at__extract_quarter AS created_at__extract_quarter + , subq_0.created_at__extract_month AS created_at__extract_month + , subq_0.created_at__extract_day AS created_at__extract_day + , subq_0.created_at__extract_dow AS created_at__extract_dow + , subq_0.created_at__extract_doy AS created_at__extract_doy + , subq_0.listing__ds__day AS listing__ds__day + , subq_0.listing__ds__week AS listing__ds__week + , subq_0.listing__ds__month AS listing__ds__month + , subq_0.listing__ds__quarter AS listing__ds__quarter + , subq_0.listing__ds__year AS listing__ds__year + , subq_0.listing__ds__extract_year AS listing__ds__extract_year + , subq_0.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_0.listing__ds__extract_month AS listing__ds__extract_month + , subq_0.listing__ds__extract_day AS listing__ds__extract_day + , subq_0.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_0.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_0.listing__created_at__day AS listing__created_at__day + , subq_0.listing__created_at__week AS listing__created_at__week + , subq_0.listing__created_at__month AS listing__created_at__month + , subq_0.listing__created_at__quarter AS listing__created_at__quarter + , subq_0.listing__created_at__year AS listing__created_at__year + , subq_0.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_0.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.user AS user + , subq_0.listing__user AS listing__user + , subq_0.country_latest AS country_latest + , subq_0.is_lux_latest AS is_lux_latest + , subq_0.capacity_latest AS capacity_latest + , subq_0.listing__country_latest AS listing__country_latest + , subq_0.listing__is_lux_latest AS listing__is_lux_latest + , subq_0.listing__capacity_latest AS listing__capacity_latest + , subq_0.listings AS listings + , subq_0.largest_listing AS largest_listing + , subq_0.smallest_listing AS smallest_listing + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.created_at__day - , subq_0.created_at__week - , subq_0.created_at__month - , subq_0.created_at__quarter - , subq_0.created_at__year - , subq_0.created_at__extract_year - , subq_0.created_at__extract_quarter - , subq_0.created_at__extract_month - , subq_0.created_at__extract_day - , subq_0.created_at__extract_dow - , subq_0.created_at__extract_doy - , subq_0.listing__ds__day - , subq_0.listing__ds__week - , subq_0.listing__ds__month - , subq_0.listing__ds__quarter - , subq_0.listing__ds__year - , subq_0.listing__ds__extract_year - , subq_0.listing__ds__extract_quarter - , subq_0.listing__ds__extract_month - , subq_0.listing__ds__extract_day - , subq_0.listing__ds__extract_dow - , subq_0.listing__ds__extract_doy - , subq_0.listing__created_at__day - , subq_0.listing__created_at__week - , subq_0.listing__created_at__month - , subq_0.listing__created_at__quarter - , subq_0.listing__created_at__year - , subq_0.listing__created_at__extract_year - , subq_0.listing__created_at__extract_quarter - , subq_0.listing__created_at__extract_month - , subq_0.listing__created_at__extract_day - , subq_0.listing__created_at__extract_dow - , subq_0.listing__created_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.user - , subq_0.listing__user - , subq_0.country_latest - , subq_0.is_lux_latest - , subq_0.capacity_latest - , subq_0.listing__country_latest - , subq_0.listing__is_lux_latest - , subq_0.listing__capacity_latest - , subq_0.listings - , subq_0.largest_listing - , subq_0.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - , subq_4.listing__ds__month -) subq_5 + subq_3.metric_time__martian_day + , subq_3.listing__ds__month +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql index 2f45574e41..091f68a2c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_metric_custom_granularity_joined_to_non_default_grain__plan0_optimized.sql @@ -1,25 +1,24 @@ --- Pass Only Elements: ['listings', 'metric_time__day', 'listing__ds__month'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day', 'listing__ds__month'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS metric_time__martian_day - , subq_7.listing__ds__month AS listing__ds__month - , SUM(subq_7.listings) AS listings + subq_6.martian_day AS metric_time__martian_day + , subq_5.listing__ds__month AS listing__ds__month + , SUM(subq_5.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('month', created_at) AS listing__ds__month - , DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day + , DATE_TRUNC('month', created_at) AS listing__ds__month FROM ***************************.dim_listings_latest listings_latest_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.metric_time__day = subq_8.ds + subq_5.ds__day = subq_6.ds GROUP BY - subq_8.martian_day - , subq_7.listing__ds__month + subq_6.martian_day + , subq_5.listing__ds__month diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0.sql index 389a1d8000..fd82862df4 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0.sql @@ -1,400 +1,388 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_6.bookings) AS bookings - , MAX(subq_13.listings) AS listings + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_5.bookings) AS bookings + , MAX(subq_11.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__martian_day - , subq_5.bookings + subq_4.metric_time__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_3.metric_time__martian_day - , subq_3.bookings + subq_2.metric_time__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__martian_day - ) subq_5 -) subq_6 + subq_3.metric_time__martian_day + ) subq_4 +) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_12.metric_time__martian_day - , subq_12.listings + subq_10.metric_time__martian_day + , subq_10.listings FROM ( -- Aggregate Measures SELECT - subq_11.metric_time__martian_day - , SUM(subq_11.listings) AS listings + subq_9.metric_time__martian_day + , SUM(subq_9.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__martian_day'] SELECT - subq_10.metric_time__martian_day - , subq_10.listings + subq_8.metric_time__martian_day + , subq_8.listings FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_8.listings AS listings - , subq_9.martian_day AS metric_time__martian_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.created_at__day AS created_at__day + , subq_6.created_at__week AS created_at__week + , subq_6.created_at__month AS created_at__month + , subq_6.created_at__quarter AS created_at__quarter + , subq_6.created_at__year AS created_at__year + , subq_6.created_at__extract_year AS created_at__extract_year + , subq_6.created_at__extract_quarter AS created_at__extract_quarter + , subq_6.created_at__extract_month AS created_at__extract_month + , subq_6.created_at__extract_day AS created_at__extract_day + , subq_6.created_at__extract_dow AS created_at__extract_dow + , subq_6.created_at__extract_doy AS created_at__extract_doy + , subq_6.listing__ds__day AS listing__ds__day + , subq_6.listing__ds__week AS listing__ds__week + , subq_6.listing__ds__month AS listing__ds__month + , subq_6.listing__ds__quarter AS listing__ds__quarter + , subq_6.listing__ds__year AS listing__ds__year + , subq_6.listing__ds__extract_year AS listing__ds__extract_year + , subq_6.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_6.listing__ds__extract_month AS listing__ds__extract_month + , subq_6.listing__ds__extract_day AS listing__ds__extract_day + , subq_6.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_6.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_6.listing__created_at__day AS listing__created_at__day + , subq_6.listing__created_at__week AS listing__created_at__week + , subq_6.listing__created_at__month AS listing__created_at__month + , subq_6.listing__created_at__quarter AS listing__created_at__quarter + , subq_6.listing__created_at__year AS listing__created_at__year + , subq_6.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_6.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_6.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_6.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_6.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_6.listing__created_at__extract_doy AS 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 AS listing + , subq_6.user AS user + , subq_6.listing__user AS listing__user + , subq_6.country_latest AS country_latest + , subq_6.is_lux_latest AS is_lux_latest + , subq_6.capacity_latest AS capacity_latest + , subq_6.listing__country_latest AS listing__country_latest + , subq_6.listing__is_lux_latest AS listing__is_lux_latest + , subq_6.listing__capacity_latest AS listing__capacity_latest + , subq_6.listings AS listings + , subq_6.largest_listing AS largest_listing + , subq_6.smallest_listing AS smallest_listing + , subq_7.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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.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.user - , subq_7.listing__user - , subq_7.country_latest - , subq_7.is_lux_latest - , subq_7.capacity_latest - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.listings - , subq_7.largest_listing - , subq_7.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_7 - ) subq_8 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds - ) subq_10 - ) subq_11 + subq_6.ds__day = subq_7.ds + ) subq_8 + ) subq_9 GROUP BY - subq_11.metric_time__martian_day - ) subq_12 -) subq_13 + subq_9.metric_time__martian_day + ) subq_10 +) subq_11 ON - subq_6.metric_time__martian_day = subq_13.metric_time__martian_day + subq_5.metric_time__martian_day = subq_11.metric_time__martian_day GROUP BY - COALESCE(subq_6.metric_time__martian_day, subq_13.metric_time__martian_day) + COALESCE(subq_5.metric_time__martian_day, subq_11.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql index e5b55102e9..ae8868ac3d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_multiple_metrics_with_custom_granularity__plan0_optimized.sql @@ -1,57 +1,55 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) AS metric_time__martian_day - , MAX(subq_20.bookings) AS bookings - , MAX(subq_27.listings) AS listings + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) AS metric_time__martian_day + , MAX(subq_17.bookings) AS bookings + , MAX(subq_23.listings) AS listings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.martian_day AS metric_time__martian_day - , SUM(subq_15.bookings) AS bookings + subq_13.martian_day AS metric_time__martian_day + , SUM(subq_12.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_12 LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_13 ON - subq_15.metric_time__day = subq_16.ds + subq_12.ds__day = subq_13.ds GROUP BY - subq_16.martian_day -) subq_20 + subq_13.martian_day +) subq_17 FULL OUTER JOIN ( - -- Pass Only Elements: ['listings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['listings', 'metric_time__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_23.martian_day AS metric_time__martian_day - , SUM(subq_22.listings) AS listings + subq_19.martian_day AS metric_time__martian_day + , SUM(subq_18.listings) AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', created_at) AS metric_time__day - , 1 AS listings + 1 AS listings + , DATE_TRUNC('day', created_at) AS ds__day FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_18 LEFT OUTER JOIN - ***************************.mf_time_spine subq_23 + ***************************.mf_time_spine subq_19 ON - subq_22.metric_time__day = subq_23.ds + subq_18.ds__day = subq_19.ds GROUP BY - subq_23.martian_day -) subq_27 + subq_19.martian_day +) subq_23 ON - subq_20.metric_time__martian_day = subq_27.metric_time__martian_day + subq_17.metric_time__martian_day = subq_23.metric_time__martian_day GROUP BY - COALESCE(subq_20.metric_time__martian_day, subq_27.metric_time__martian_day) + COALESCE(subq_17.metric_time__martian_day, subq_23.metric_time__martian_day) diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql index 8001396a41..39ae456b28 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0.sql @@ -1,341 +1,335 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__martian_day + subq_8.booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_8.booking__ds__martian_day - , subq_8.bookings AS bookings_5_days_ago + subq_7.booking__ds__martian_day + , subq_7.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_7.booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.booking__ds__martian_day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_6.booking__ds__martian_day - , subq_6.bookings + subq_5.booking__ds__martian_day + , subq_5.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.booking__ds__day AS booking__ds__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS booking__ds__martian_day + subq_2.booking__ds__day AS booking__ds__day + , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week + , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month + , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter + , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year + , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year + , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter + , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month + , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.booking__ds__day) AS booking__ds__extract_dow + , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy + , 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_4.martian_day AS booking__ds__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.booking__ds__day AS booking__ds__day - , DATE_TRUNC('week', subq_2.booking__ds__day) AS booking__ds__week - , DATE_TRUNC('month', subq_2.booking__ds__day) AS booking__ds__month - , DATE_TRUNC('quarter', subq_2.booking__ds__day) AS booking__ds__quarter - , DATE_TRUNC('year', subq_2.booking__ds__day) AS booking__ds__year - , EXTRACT(year FROM subq_2.booking__ds__day) AS booking__ds__extract_year - , EXTRACT(quarter FROM subq_2.booking__ds__day) AS booking__ds__extract_quarter - , EXTRACT(month FROM subq_2.booking__ds__day) AS booking__ds__extract_month - , EXTRACT(day FROM subq_2.booking__ds__day) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_2.booking__ds__day) AS booking__ds__extract_dow - , EXTRACT(doy FROM subq_2.booking__ds__day) AS booking__ds__extract_doy - , 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_3.ds AS booking__ds__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS booking__ds__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_ADD('day', -5, subq_2.booking__ds__day) = subq_1.booking__ds__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_ADD('day', -5, subq_2.booking__ds__day) = subq_1.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.booking__ds__day = subq_5.ds - ) subq_6 - ) subq_7 + subq_2.booking__ds__day = subq_4.ds + ) subq_5 + ) subq_6 GROUP BY - subq_7.booking__ds__martian_day - ) subq_8 -) subq_9 + subq_6.booking__ds__martian_day + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0_optimized.sql index b4e08ad793..60ce5ce312 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity__plan0_optimized.sql @@ -3,35 +3,29 @@ SELECT booking__ds__martian_day , bookings_5_days_ago AS bookings_5_day_lag FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.martian_day AS booking__ds__martian_day - , SUM(subq_14.bookings) AS bookings_5_days_ago - FROM ( - -- Join to Time Spine Dataset + subq_13.martian_day AS booking__ds__martian_day + , SUM(subq_10.bookings) AS bookings_5_days_ago + FROM ***************************.mf_time_spine subq_12 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_13.ds AS booking__ds__day - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 - 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_28000 - ) subq_11 - ON - DATE_ADD('day', -5, subq_13.ds) = subq_11.booking__ds__day - ) subq_14 + DATE_TRUNC('day', ds) AS booking__ds__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ON + DATE_ADD('day', -5, subq_12.ds) = subq_10.booking__ds__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_15 + ***************************.mf_time_spine subq_13 ON - subq_14.booking__ds__day = subq_15.ds + subq_12.ds = subq_13.ds GROUP BY - subq_15.martian_day -) subq_19 + subq_13.martian_day +) subq_17 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 9b806d6242..c971ebc6db 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -1,349 +1,439 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day + subq_9.metric_time__day , bookings_5_days_ago AS bookings_5_day_lag FROM ( -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_5_days_ago + subq_8.metric_time__day + , subq_8.bookings AS bookings_5_days_ago FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_7.metric_time__day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_6.metric_time__day + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__martian_day - , subq_6.metric_time__day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.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.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 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_4.metric_time__day AS metric_time__day - , subq_4.bookings AS bookings - , subq_5.martian_day AS metric_time__martian_day + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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_4.martian_day AS metric_time__martian_day FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_ADD('day', -5, subq_2.metric_time__day) = subq_1.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_5 + ***************************.mf_time_spine subq_4 ON - subq_4.metric_time__day = subq_5.ds - ) subq_6 + subq_2.metric_time__day = subq_4.ds + ) subq_5 WHERE metric_time__martian_day = '2020-01-01' - ) subq_7 - ) subq_8 + ) subq_6 + ) subq_7 GROUP BY - subq_8.metric_time__day - ) subq_9 -) subq_10 + subq_7.metric_time__day + ) subq_8 +) subq_9 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql index 6b2ee21649..f5b2f59fc8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0_optimized.sql @@ -11,35 +11,29 @@ FROM ( metric_time__day , SUM(bookings) AS bookings_5_days_ago FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] + -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings - , subq_16.martian_day AS metric_time__martian_day - FROM ( - -- Join to Time Spine Dataset + subq_13.ds AS metric_time__day + , subq_11.bookings AS bookings + , subq_14.martian_day AS metric_time__martian_day + FROM ***************************.mf_time_spine subq_13 + INNER JOIN ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - subq_14.ds AS metric_time__day - , subq_12.bookings AS bookings - FROM ***************************.mf_time_spine subq_14 - 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_28000 - ) subq_12 - ON - DATE_ADD('day', -5, subq_14.ds) = subq_12.metric_time__day - ) subq_15 + DATE_TRUNC('day', ds) AS metric_time__day + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_11 + ON + DATE_ADD('day', -5, subq_13.ds) = subq_11.metric_time__day LEFT OUTER JOIN - ***************************.mf_time_spine subq_16 + ***************************.mf_time_spine subq_14 ON - subq_15.metric_time__day = subq_16.ds - ) subq_17 + subq_13.ds = subq_14.ds + ) subq_15 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__day -) subq_21 +) subq_19 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0.sql index 82d926fd5a..485f396d41 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0.sql @@ -1,225 +1,219 @@ -- Compute Metrics via Expressions SELECT - subq_5.booking__ds__martian_day - , subq_5.bookings + subq_4.booking__ds__martian_day + , subq_4.bookings FROM ( -- Aggregate Measures SELECT - subq_4.booking__ds__martian_day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__martian_day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] SELECT - subq_3.booking__ds__martian_day - , subq_3.bookings + subq_2.booking__ds__martian_day + , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.booking__ds__day AS booking__ds__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS booking__ds__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS booking__ds__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.booking__ds__day = subq_2.ds - ) subq_3 - ) subq_4 + subq_0.booking__ds__day = subq_1.ds + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__martian_day -) subq_5 + subq_3.booking__ds__martian_day +) subq_4 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0_optimized.sql index fade916c75..ec04bb54d3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity__plan0_optimized.sql @@ -1,22 +1,21 @@ --- Pass Only Elements: ['bookings', 'booking__ds__day'] +-- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_8.martian_day AS booking__ds__martian_day - , SUM(subq_7.bookings) AS bookings + subq_6.martian_day AS booking__ds__martian_day + , SUM(subq_5.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS booking__ds__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS booking__ds__day FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_7 +) subq_5 LEFT OUTER JOIN - ***************************.mf_time_spine subq_8 + ***************************.mf_time_spine subq_6 ON - subq_7.booking__ds__day = subq_8.ds + subq_5.booking__ds__day = subq_6.ds GROUP BY - subq_8.martian_day + subq_6.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0.sql index ce78dd0d38..aab3d10a4a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0.sql @@ -1,378 +1,462 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__ds__martian_day - , subq_10.bookings + subq_8.listing__ds__martian_day + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__ds__martian_day - , SUM(subq_9.bookings) AS bookings + subq_7.listing__ds__martian_day + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] SELECT - subq_8.listing__ds__martian_day - , subq_8.bookings + subq_6.listing__ds__martian_day + , subq_6.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_6.listing__ds__day AS listing__ds__day - , subq_6.bookings AS bookings - , subq_7.martian_day AS listing__ds__martian_day + subq_4.ds__day AS listing__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__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__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_5.martian_day AS listing__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.ds__day AS listing__ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds__day', 'listing'] + SELECT + subq_3.ds__day + , subq_3.listing + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.ds__day - , subq_4.listing + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing LEFT OUTER JOIN - ***************************.mf_time_spine subq_7 + ***************************.mf_time_spine subq_5 ON - subq_6.listing__ds__day = subq_7.ds - ) subq_8 - ) subq_9 + subq_4.ds__day = subq_5.ds + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__ds__martian_day -) subq_10 + subq_7.listing__ds__martian_day +) subq_8 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql index f36ac75d16..3b149b39b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_and_join__plan0_optimized.sql @@ -1,33 +1,26 @@ --- Pass Only Elements: ['bookings', 'listing__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_18.martian_day AS listing__ds__martian_day - , SUM(subq_17.bookings) AS bookings + subq_14.martian_day AS listing__ds__martian_day + , SUM(subq_10.bookings) AS bookings FROM ( - -- Join Standard Outputs + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , subq_13.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'listing'] - SELECT - listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_28000 - ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_17 + listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_10 LEFT OUTER JOIN - ***************************.mf_time_spine subq_18 + ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_17.listing__ds__day = subq_18.ds + subq_10.listing = listings_latest_src_28000.listing_id +LEFT OUTER JOIN + ***************************.mf_time_spine subq_14 +ON + DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_14.ds GROUP BY - subq_18.martian_day + subq_14.martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0.sql index a2d1659298..63fbcb878f 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0.sql @@ -1,228 +1,318 @@ -- Compute Metrics via Expressions SELECT - subq_6.bookings + subq_5.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_5.bookings) AS bookings + SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings',] SELECT - subq_4.bookings + subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 -) subq_6 + ) subq_3 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql index 28f1b6995f..1ea0cb2615 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_filter__plan0_optimized.sql @@ -5,22 +5,21 @@ SELECT SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql index 5aa6cf582e..cf700e14a3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0.sql @@ -1,233 +1,323 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__martian_day - , subq_6.bookings + subq_5.metric_time__martian_day + , subq_5.bookings FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__martian_day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__martian_day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__martian_day'] SELECT - subq_4.metric_time__martian_day - , subq_4.bookings + subq_3.metric_time__martian_day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__martian_day - , subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__martian_day + , 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_1.metric_time__day AS metric_time__day - , subq_1.bookings AS bookings - , subq_2.martian_day AS metric_time__martian_day + 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.ds_partitioned__day AS ds_partitioned__day + , subq_0.ds_partitioned__week AS ds_partitioned__week + , subq_0.ds_partitioned__month AS ds_partitioned__month + , subq_0.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_0.ds_partitioned__year AS ds_partitioned__year + , subq_0.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_0.paid_at__day AS paid_at__day + , subq_0.paid_at__week AS paid_at__week + , subq_0.paid_at__month AS paid_at__month + , subq_0.paid_at__quarter AS paid_at__quarter + , subq_0.paid_at__year AS paid_at__year + , subq_0.paid_at__extract_year AS paid_at__extract_year + , subq_0.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_0.paid_at__extract_month AS paid_at__extract_month + , subq_0.paid_at__extract_day AS paid_at__extract_day + , subq_0.paid_at__extract_dow AS paid_at__extract_dow + , subq_0.paid_at__extract_doy AS paid_at__extract_doy + , subq_0.booking__ds__day AS booking__ds__day + , subq_0.booking__ds__week AS booking__ds__week + , subq_0.booking__ds__month AS booking__ds__month + , subq_0.booking__ds__quarter AS booking__ds__quarter + , subq_0.booking__ds__year AS booking__ds__year + , subq_0.booking__ds__extract_year AS booking__ds__extract_year + , subq_0.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_0.booking__ds__extract_month AS booking__ds__extract_month + , subq_0.booking__ds__extract_day AS booking__ds__extract_day + , subq_0.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_0.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day AS booking__paid_at__day + , subq_0.booking__paid_at__week AS booking__paid_at__week + , subq_0.booking__paid_at__month AS booking__paid_at__month + , subq_0.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_0.booking__paid_at__year AS booking__paid_at__year + , subq_0.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing AS listing + , subq_0.guest AS guest + , subq_0.host AS host + , subq_0.booking__listing AS booking__listing + , subq_0.booking__guest AS booking__guest + , subq_0.booking__host AS booking__host + , subq_0.is_instant AS is_instant + , subq_0.booking__is_instant AS booking__is_instant + , subq_0.bookings AS bookings + , subq_0.instant_bookings AS instant_bookings + , subq_0.booking_value AS booking_value + , subq_0.max_booking_value AS max_booking_value + , subq_0.min_booking_value AS min_booking_value + , subq_0.bookers AS bookers + , subq_0.average_booking_value AS average_booking_value + , subq_0.referred_bookings AS referred_bookings + , subq_0.median_booking_value AS median_booking_value + , subq_0.booking_value_p99 AS booking_value_p99 + , subq_0.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 + , subq_1.martian_day AS metric_time__martian_day FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 LEFT OUTER JOIN - ***************************.mf_time_spine subq_2 + ***************************.mf_time_spine subq_1 ON - subq_1.metric_time__day = subq_2.ds - ) subq_3 + subq_0.ds__day = subq_1.ds + ) subq_2 WHERE metric_time__martian_day = '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__martian_day -) subq_6 + subq_4.metric_time__martian_day +) subq_5 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql index 8c1f6de498..e5498b173a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_custom_granularity_in_filter_and_group_by__plan0_optimized.sql @@ -6,24 +6,23 @@ SELECT metric_time__martian_day , SUM(bookings) AS bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Metric Time Dimension 'ds' -- Join to Custom Granularity Dataset SELECT - subq_8.bookings AS bookings - , subq_9.martian_day AS metric_time__martian_day + subq_6.bookings AS bookings + , subq_7.martian_day AS metric_time__martian_day FROM ( -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , 1 AS bookings + 1 AS bookings + , DATE_TRUNC('day', ds) AS ds__day FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 + ) subq_6 LEFT OUTER JOIN - ***************************.mf_time_spine subq_9 + ***************************.mf_time_spine subq_7 ON - subq_8.metric_time__day = subq_9.ds -) subq_10 + subq_6.ds__day = subq_7.ds +) subq_8 WHERE metric_time__martian_day = '2020-01-01' GROUP BY metric_time__martian_day diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql index 780f8655ae..2e00a59027 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql @@ -1,1316 +1,1398 @@ -- Compute Metrics via Expressions SELECT - subq_14.listing__user__ds__martian_day - , subq_14.bookings + subq_12.listing__user__ds__martian_day + , subq_12.bookings FROM ( -- Aggregate Measures SELECT - subq_13.listing__user__ds__martian_day - , SUM(subq_13.bookings) AS bookings + subq_11.listing__user__ds__martian_day + , SUM(subq_11.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] SELECT - subq_12.listing__user__ds__martian_day - , subq_12.bookings + subq_10.listing__user__ds__martian_day + , subq_10.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing__user__ds__day'] + -- Join Standard Outputs -- Join to Custom Granularity Dataset SELECT - subq_10.listing__user__ds__day AS listing__user__ds__day - , subq_10.bookings AS bookings - , subq_11.martian_day AS listing__user__ds__martian_day + subq_8.user__ds__day AS listing__user__ds__day + , subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__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__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_9.martian_day AS listing__user__ds__martian_day FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_9.user__ds__day AS listing__user__ds__day - , subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] + SELECT + subq_7.user__ds__day + , subq_7.user__ds_partitioned__day + , subq_7.listing + FROM ( + -- Join Standard Outputs + SELECT + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing FROM ( -- Metric Time Dimension 'ds' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Read Elements From Semantic Model 'bookings_source' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - subq_8.user__ds__day - , subq_8.user__ds_partitioned__day - , subq_8.listing - FROM ( - -- Join Standard Outputs + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'home_state', + -- 'user__home_state', + -- 'ds__day', + -- 'ds__week', + -- 'ds__month', + -- 'ds__quarter', + -- 'ds__year', + -- 'ds__extract_year', + -- 'ds__extract_quarter', + -- 'ds__extract_month', + -- 'ds__extract_day', + -- 'ds__extract_dow', + -- 'ds__extract_doy', + -- 'created_at__day', + -- 'created_at__week', + -- 'created_at__month', + -- 'created_at__quarter', + -- 'created_at__year', + -- 'created_at__extract_year', + -- 'created_at__extract_quarter', + -- 'created_at__extract_month', + -- 'created_at__extract_day', + -- 'created_at__extract_dow', + -- 'created_at__extract_doy', + -- 'ds_partitioned__day', + -- 'ds_partitioned__week', + -- 'ds_partitioned__month', + -- 'ds_partitioned__quarter', + -- 'ds_partitioned__year', + -- 'ds_partitioned__extract_year', + -- 'ds_partitioned__extract_quarter', + -- 'ds_partitioned__extract_month', + -- 'ds_partitioned__extract_day', + -- 'ds_partitioned__extract_dow', + -- 'ds_partitioned__extract_doy', + -- 'last_profile_edit_ts__millisecond', + -- 'last_profile_edit_ts__second', + -- 'last_profile_edit_ts__minute', + -- 'last_profile_edit_ts__hour', + -- 'last_profile_edit_ts__day', + -- 'last_profile_edit_ts__week', + -- 'last_profile_edit_ts__month', + -- 'last_profile_edit_ts__quarter', + -- 'last_profile_edit_ts__year', + -- 'last_profile_edit_ts__extract_year', + -- 'last_profile_edit_ts__extract_quarter', + -- 'last_profile_edit_ts__extract_month', + -- 'last_profile_edit_ts__extract_day', + -- 'last_profile_edit_ts__extract_dow', + -- 'last_profile_edit_ts__extract_doy', + -- 'bio_added_ts__second', + -- 'bio_added_ts__minute', + -- 'bio_added_ts__hour', + -- 'bio_added_ts__day', + -- 'bio_added_ts__week', + -- 'bio_added_ts__month', + -- 'bio_added_ts__quarter', + -- 'bio_added_ts__year', + -- 'bio_added_ts__extract_year', + -- 'bio_added_ts__extract_quarter', + -- 'bio_added_ts__extract_month', + -- 'bio_added_ts__extract_day', + -- 'bio_added_ts__extract_dow', + -- 'bio_added_ts__extract_doy', + -- 'last_login_ts__minute', + -- 'last_login_ts__hour', + -- 'last_login_ts__day', + -- 'last_login_ts__week', + -- 'last_login_ts__month', + -- 'last_login_ts__quarter', + -- 'last_login_ts__year', + -- 'last_login_ts__extract_year', + -- 'last_login_ts__extract_quarter', + -- 'last_login_ts__extract_month', + -- 'last_login_ts__extract_day', + -- 'last_login_ts__extract_dow', + -- 'last_login_ts__extract_doy', + -- 'archived_at__hour', + -- 'archived_at__day', + -- 'archived_at__week', + -- 'archived_at__month', + -- 'archived_at__quarter', + -- 'archived_at__year', + -- 'archived_at__extract_year', + -- 'archived_at__extract_quarter', + -- 'archived_at__extract_month', + -- 'archived_at__extract_day', + -- 'archived_at__extract_dow', + -- 'archived_at__extract_doy', + -- 'user__ds__day', + -- 'user__ds__week', + -- 'user__ds__month', + -- 'user__ds__quarter', + -- 'user__ds__year', + -- 'user__ds__extract_year', + -- 'user__ds__extract_quarter', + -- 'user__ds__extract_month', + -- 'user__ds__extract_day', + -- 'user__ds__extract_dow', + -- 'user__ds__extract_doy', + -- 'user__created_at__day', + -- 'user__created_at__week', + -- 'user__created_at__month', + -- 'user__created_at__quarter', + -- 'user__created_at__year', + -- 'user__created_at__extract_year', + -- 'user__created_at__extract_quarter', + -- 'user__created_at__extract_month', + -- 'user__created_at__extract_day', + -- 'user__created_at__extract_dow', + -- 'user__created_at__extract_doy', + -- 'user__ds_partitioned__day', + -- 'user__ds_partitioned__week', + -- 'user__ds_partitioned__month', + -- 'user__ds_partitioned__quarter', + -- 'user__ds_partitioned__year', + -- 'user__ds_partitioned__extract_year', + -- 'user__ds_partitioned__extract_quarter', + -- 'user__ds_partitioned__extract_month', + -- 'user__ds_partitioned__extract_day', + -- 'user__ds_partitioned__extract_dow', + -- 'user__ds_partitioned__extract_doy', + -- 'user__last_profile_edit_ts__millisecond', + -- 'user__last_profile_edit_ts__second', + -- 'user__last_profile_edit_ts__minute', + -- 'user__last_profile_edit_ts__hour', + -- 'user__last_profile_edit_ts__day', + -- 'user__last_profile_edit_ts__week', + -- 'user__last_profile_edit_ts__month', + -- 'user__last_profile_edit_ts__quarter', + -- 'user__last_profile_edit_ts__year', + -- 'user__last_profile_edit_ts__extract_year', + -- 'user__last_profile_edit_ts__extract_quarter', + -- 'user__last_profile_edit_ts__extract_month', + -- 'user__last_profile_edit_ts__extract_day', + -- 'user__last_profile_edit_ts__extract_dow', + -- 'user__last_profile_edit_ts__extract_doy', + -- 'user__bio_added_ts__second', + -- 'user__bio_added_ts__minute', + -- 'user__bio_added_ts__hour', + -- 'user__bio_added_ts__day', + -- 'user__bio_added_ts__week', + -- 'user__bio_added_ts__month', + -- 'user__bio_added_ts__quarter', + -- 'user__bio_added_ts__year', + -- 'user__bio_added_ts__extract_year', + -- 'user__bio_added_ts__extract_quarter', + -- 'user__bio_added_ts__extract_month', + -- 'user__bio_added_ts__extract_day', + -- 'user__bio_added_ts__extract_dow', + -- 'user__bio_added_ts__extract_doy', + -- 'user__last_login_ts__minute', + -- 'user__last_login_ts__hour', + -- 'user__last_login_ts__day', + -- 'user__last_login_ts__week', + -- 'user__last_login_ts__month', + -- 'user__last_login_ts__quarter', + -- 'user__last_login_ts__year', + -- 'user__last_login_ts__extract_year', + -- 'user__last_login_ts__extract_quarter', + -- 'user__last_login_ts__extract_month', + -- 'user__last_login_ts__extract_day', + -- 'user__last_login_ts__extract_dow', + -- 'user__last_login_ts__extract_doy', + -- 'user__archived_at__hour', + -- 'user__archived_at__day', + -- 'user__archived_at__week', + -- 'user__archived_at__month', + -- 'user__archived_at__quarter', + -- 'user__archived_at__year', + -- 'user__archived_at__extract_year', + -- 'user__archived_at__extract_quarter', + -- 'user__archived_at__extract_month', + -- 'user__archived_at__extract_day', + -- 'user__archived_at__extract_dow', + -- 'user__archived_at__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'user', + -- ] SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'created_at' 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_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'home_state', - -- 'user__home_state', - -- 'ds__day', - -- 'ds__week', - -- 'ds__month', - -- 'ds__quarter', - -- 'ds__year', - -- 'ds__extract_year', - -- 'ds__extract_quarter', - -- 'ds__extract_month', - -- 'ds__extract_day', - -- 'ds__extract_dow', - -- 'ds__extract_doy', - -- 'created_at__day', - -- 'created_at__week', - -- 'created_at__month', - -- 'created_at__quarter', - -- 'created_at__year', - -- 'created_at__extract_year', - -- 'created_at__extract_quarter', - -- 'created_at__extract_month', - -- 'created_at__extract_day', - -- 'created_at__extract_dow', - -- 'created_at__extract_doy', - -- 'ds_partitioned__day', - -- 'ds_partitioned__week', - -- 'ds_partitioned__month', - -- 'ds_partitioned__quarter', - -- 'ds_partitioned__year', - -- 'ds_partitioned__extract_year', - -- 'ds_partitioned__extract_quarter', - -- 'ds_partitioned__extract_month', - -- 'ds_partitioned__extract_day', - -- 'ds_partitioned__extract_dow', - -- 'ds_partitioned__extract_doy', - -- 'last_profile_edit_ts__millisecond', - -- 'last_profile_edit_ts__second', - -- 'last_profile_edit_ts__minute', - -- 'last_profile_edit_ts__hour', - -- 'last_profile_edit_ts__day', - -- 'last_profile_edit_ts__week', - -- 'last_profile_edit_ts__month', - -- 'last_profile_edit_ts__quarter', - -- 'last_profile_edit_ts__year', - -- 'last_profile_edit_ts__extract_year', - -- 'last_profile_edit_ts__extract_quarter', - -- 'last_profile_edit_ts__extract_month', - -- 'last_profile_edit_ts__extract_day', - -- 'last_profile_edit_ts__extract_dow', - -- 'last_profile_edit_ts__extract_doy', - -- 'bio_added_ts__second', - -- 'bio_added_ts__minute', - -- 'bio_added_ts__hour', - -- 'bio_added_ts__day', - -- 'bio_added_ts__week', - -- 'bio_added_ts__month', - -- 'bio_added_ts__quarter', - -- 'bio_added_ts__year', - -- 'bio_added_ts__extract_year', - -- 'bio_added_ts__extract_quarter', - -- 'bio_added_ts__extract_month', - -- 'bio_added_ts__extract_day', - -- 'bio_added_ts__extract_dow', - -- 'bio_added_ts__extract_doy', - -- 'last_login_ts__minute', - -- 'last_login_ts__hour', - -- 'last_login_ts__day', - -- 'last_login_ts__week', - -- 'last_login_ts__month', - -- 'last_login_ts__quarter', - -- 'last_login_ts__year', - -- 'last_login_ts__extract_year', - -- 'last_login_ts__extract_quarter', - -- 'last_login_ts__extract_month', - -- 'last_login_ts__extract_day', - -- 'last_login_ts__extract_dow', - -- 'last_login_ts__extract_doy', - -- 'archived_at__hour', - -- 'archived_at__day', - -- 'archived_at__week', - -- 'archived_at__month', - -- 'archived_at__quarter', - -- 'archived_at__year', - -- 'archived_at__extract_year', - -- 'archived_at__extract_quarter', - -- 'archived_at__extract_month', - -- 'archived_at__extract_day', - -- 'archived_at__extract_dow', - -- 'archived_at__extract_doy', - -- 'user__ds__day', - -- 'user__ds__week', - -- 'user__ds__month', - -- 'user__ds__quarter', - -- 'user__ds__year', - -- 'user__ds__extract_year', - -- 'user__ds__extract_quarter', - -- 'user__ds__extract_month', - -- 'user__ds__extract_day', - -- 'user__ds__extract_dow', - -- 'user__ds__extract_doy', - -- 'user__created_at__day', - -- 'user__created_at__week', - -- 'user__created_at__month', - -- 'user__created_at__quarter', - -- 'user__created_at__year', - -- 'user__created_at__extract_year', - -- 'user__created_at__extract_quarter', - -- 'user__created_at__extract_month', - -- 'user__created_at__extract_day', - -- 'user__created_at__extract_dow', - -- 'user__created_at__extract_doy', - -- 'user__ds_partitioned__day', - -- 'user__ds_partitioned__week', - -- 'user__ds_partitioned__month', - -- 'user__ds_partitioned__quarter', - -- 'user__ds_partitioned__year', - -- 'user__ds_partitioned__extract_year', - -- 'user__ds_partitioned__extract_quarter', - -- 'user__ds_partitioned__extract_month', - -- 'user__ds_partitioned__extract_day', - -- 'user__ds_partitioned__extract_dow', - -- 'user__ds_partitioned__extract_doy', - -- 'user__last_profile_edit_ts__millisecond', - -- 'user__last_profile_edit_ts__second', - -- 'user__last_profile_edit_ts__minute', - -- 'user__last_profile_edit_ts__hour', - -- 'user__last_profile_edit_ts__day', - -- 'user__last_profile_edit_ts__week', - -- 'user__last_profile_edit_ts__month', - -- 'user__last_profile_edit_ts__quarter', - -- 'user__last_profile_edit_ts__year', - -- 'user__last_profile_edit_ts__extract_year', - -- 'user__last_profile_edit_ts__extract_quarter', - -- 'user__last_profile_edit_ts__extract_month', - -- 'user__last_profile_edit_ts__extract_day', - -- 'user__last_profile_edit_ts__extract_dow', - -- 'user__last_profile_edit_ts__extract_doy', - -- 'user__bio_added_ts__second', - -- 'user__bio_added_ts__minute', - -- 'user__bio_added_ts__hour', - -- 'user__bio_added_ts__day', - -- 'user__bio_added_ts__week', - -- 'user__bio_added_ts__month', - -- 'user__bio_added_ts__quarter', - -- 'user__bio_added_ts__year', - -- 'user__bio_added_ts__extract_year', - -- 'user__bio_added_ts__extract_quarter', - -- 'user__bio_added_ts__extract_month', - -- 'user__bio_added_ts__extract_day', - -- 'user__bio_added_ts__extract_dow', - -- 'user__bio_added_ts__extract_doy', - -- 'user__last_login_ts__minute', - -- 'user__last_login_ts__hour', - -- 'user__last_login_ts__day', - -- 'user__last_login_ts__week', - -- 'user__last_login_ts__month', - -- 'user__last_login_ts__quarter', - -- 'user__last_login_ts__year', - -- 'user__last_login_ts__extract_year', - -- 'user__last_login_ts__extract_quarter', - -- 'user__last_login_ts__extract_month', - -- 'user__last_login_ts__extract_day', - -- 'user__last_login_ts__extract_dow', - -- 'user__last_login_ts__extract_doy', - -- 'user__archived_at__hour', - -- 'user__archived_at__day', - -- 'user__archived_at__week', - -- 'user__archived_at__month', - -- 'user__archived_at__quarter', - -- 'user__archived_at__year', - -- 'user__archived_at__extract_year', - -- 'user__archived_at__extract_quarter', - -- 'user__archived_at__extract_month', - -- 'user__archived_at__extract_day', - -- 'user__archived_at__extract_dow', - -- 'user__archived_at__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'user', - -- ] - 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state - FROM ( - -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 - ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 - ON - ( - subq_2.listing = subq_9.listing - ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day - ) - ) subq_10 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_4 + ) subq_5 + ) subq_6 + ON + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 + ON + ( + subq_1.listing = subq_8.listing + ) AND ( + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_11 + ***************************.mf_time_spine subq_9 ON - subq_10.listing__user__ds__day = subq_11.ds - ) subq_12 - ) subq_13 + subq_8.user__ds__day = subq_9.ds + ) subq_10 + ) subq_11 GROUP BY - subq_13.listing__user__ds__martian_day -) subq_14 + subq_11.listing__user__ds__martian_day +) subq_12 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql index 4d3c50e9a2..71414f4240 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/Trino/test_simple_metric_with_multi_hop_custom_granularity__plan0_optimized.sql @@ -1,49 +1,42 @@ --- Pass Only Elements: ['bookings', 'listing__user__ds__day'] +-- Join Standard Outputs -- Join to Custom Granularity Dataset -- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_26.martian_day AS listing__user__ds__martian_day - , SUM(subq_25.bookings) AS bookings + subq_22.martian_day AS listing__user__ds__martian_day + , SUM(subq_14.bookings) AS bookings FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + SELECT + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_28000 +) subq_14 +LEFT OUTER JOIN ( -- Join Standard Outputs + -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] SELECT - subq_24.user__ds__day AS listing__user__ds__day - , subq_17.bookings AS bookings - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] - SELECT - DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_17 - LEFT OUTER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] - SELECT - DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day - , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day - , listings_latest_src_28000.listing_id AS listing - FROM ***************************.dim_listings_latest listings_latest_src_28000 - LEFT OUTER JOIN - ***************************.dim_users users_ds_source_src_28000 - ON - listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id - ) subq_24 + DATE_TRUNC('day', users_ds_source_src_28000.ds) AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) AS user__ds_partitioned__day + , listings_latest_src_28000.listing_id AS listing + FROM ***************************.dim_listings_latest listings_latest_src_28000 + LEFT OUTER JOIN + ***************************.dim_users users_ds_source_src_28000 ON - ( - subq_17.listing = subq_24.listing - ) AND ( - subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day - ) -) subq_25 + listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id +) subq_21 +ON + ( + subq_14.listing = subq_21.listing + ) AND ( + subq_14.ds_partitioned__day = subq_21.user__ds_partitioned__day + ) LEFT OUTER JOIN - ***************************.mf_time_spine subq_26 + ***************************.mf_time_spine subq_22 ON - subq_25.listing__user__ds__day = subq_26.ds + subq_21.user__ds__day = subq_22.ds GROUP BY - subq_26.martian_day + subq_22.martian_day diff --git a/tests_metricflow/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml b/tests_metricflow/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml index 2c9fa8f657..62e87117ce 100644 --- a/tests_metricflow/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml +++ b/tests_metricflow/snapshots/test_cyclic_join.py/DataflowPlan/test_cyclic_join__dfp_0.xml @@ -11,7 +11,7 @@ - + @@ -22,32 +22,25 @@ - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_saved_query_tasks__query0.sql index 06127e85cb..f8ae12667d 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATETIME_TRUNC(ds, day) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_saved_query_tasks__query0.sql index d76ce501d3..950c501eba 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_saved_query_tasks__query0.sql index d76ce501d3..950c501eba 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_saved_query_tasks__query0.sql index d76ce501d3..950c501eba 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_saved_query_tasks__query0.sql index d76ce501d3..950c501eba 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_saved_query_tasks__query0.sql b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_saved_query_tasks__query0.sql index d76ce501d3..950c501eba 100644 --- a/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_saved_query_tasks__query0.sql +++ b/tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_saved_query_tasks__query0.sql @@ -5,10 +5,10 @@ SELECT , SUM(instant_bookings) AS instant_bookings FROM ( SELECT - subq_2.metric_time__day AS metric_time__day - , listings_latest_src_10000.capacity AS listing__capacity_latest - , subq_2.bookings AS bookings - , subq_2.instant_bookings AS instant_bookings + listings_latest_src_10000.capacity AS listing__capacity_latest + , subq_1.metric_time__day AS metric_time__day + , subq_1.bookings AS bookings + , subq_1.instant_bookings AS instant_bookings FROM ( SELECT DATE_TRUNC('day', ds) AS metric_time__day @@ -16,12 +16,12 @@ FROM ( , 1 AS bookings , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10000 - ) subq_2 + ) subq_1 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_10000 ON - subq_2.listing = listings_latest_src_10000.listing_id -) subq_7 + subq_1.listing = listings_latest_src_10000.listing_id +) subq_5 WHERE listing__capacity_latest > 3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml index d44a1d8cc7..67e5db8a0e 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml @@ -15,7 +15,7 @@ - + @@ -31,37 +31,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + @@ -90,7 +78,7 @@ - + @@ -106,38 +94,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml index 3b7260c7f7..bc6553cc83 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml @@ -77,56 +77,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,8 +144,8 @@ - - + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml index d0b65a445a..fb8cfac2cb 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_joined_plan__dfp_0.xml @@ -12,7 +12,7 @@ - + @@ -28,37 +28,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml index 3e29ccc96e..44836ee34a 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml @@ -76,7 +76,7 @@ - + @@ -136,80 +136,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -280,7 +243,7 @@ - + @@ -340,79 +303,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -426,7 +353,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml index c2d6ada469..db61907727 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml @@ -67,7 +67,7 @@ - + @@ -117,34 +117,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -158,7 +140,7 @@ - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_metric_where_filter__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_metric_where_filter__dfp_0.xml index 9b9e3a4b03..95e30f9ec7 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_metric_where_filter__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_metric_where_filter__dfp_0.xml @@ -11,7 +11,7 @@ - + @@ -39,85 +39,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_query_where_filter__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_query_where_filter__dfp_0.xml index ae05692016..d5328a2262 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_query_where_filter__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_metric_in_query_where_filter__dfp_0.xml @@ -39,7 +39,7 @@ - + @@ -67,85 +67,66 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml index 7267b277a1..da1ec9cea4 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -19,7 +19,7 @@ - + @@ -35,37 +35,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + @@ -94,7 +82,7 @@ - + @@ -110,37 +98,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml index 378d694411..01565ae1f7 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multihop_join_plan__dfp_0.xml @@ -11,7 +11,7 @@ - + @@ -25,9 +25,9 @@ - + - + @@ -49,33 +49,21 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml index 67d87187d3..9adf30308f 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -107,7 +107,7 @@ - + @@ -155,50 +155,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml index 1a9ca252dc..ec4b9441a0 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -109,7 +109,7 @@ - + @@ -157,54 +157,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -263,7 +242,7 @@ - + @@ -311,36 +290,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml index 0338b8353f..44bed7b48f 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -19,7 +19,7 @@ - + @@ -35,37 +35,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + @@ -94,7 +82,7 @@ - + @@ -110,37 +98,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml index f505e974f8..938ce395f0 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan__dfp_0.xml @@ -68,7 +68,7 @@ - + @@ -128,73 +128,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml index 358dba7b2d..5cac881e66 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_plan_time_dimension__dfp_0.xml @@ -56,7 +56,7 @@ - + @@ -104,33 +104,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml index f990315db9..001ed5ddd6 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_where_constrained_with_common_linkable_plan__dfp_0.xml @@ -66,97 +66,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + - + @@ -172,8 +165,8 @@ - - + + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml index 8fccf02d64..bfbeda78de 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_joined_plan__ep_0.xml @@ -8,23 +8,22 @@ - + - + - - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml index 5862f3c965..75711156bb 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,12 +28,12 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml index f231dbcccd..b3e3698b3b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_joined_plan__ep_0.xml @@ -8,25 +8,24 @@ - + - + - - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml index 11c8105735..8682d4e277 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,14 +28,14 @@ - + - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml index f231dbcccd..b3e3698b3b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_joined_plan__ep_0.xml @@ -8,25 +8,24 @@ - + - + - - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml index 11c8105735..8682d4e277 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,14 +28,14 @@ - + - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml index f231dbcccd..b3e3698b3b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_joined_plan__ep_0.xml @@ -8,25 +8,24 @@ - + - + - - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml index 11c8105735..8682d4e277 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,14 +28,14 @@ - + - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml index f231dbcccd..b3e3698b3b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_joined_plan__ep_0.xml @@ -8,25 +8,24 @@ - + - + - - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml index 11c8105735..8682d4e277 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,14 +28,14 @@ - + - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml index f231dbcccd..b3e3698b3b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_joined_plan__ep_0.xml @@ -8,25 +8,24 @@ - + - + - - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml index 11c8105735..8682d4e277 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Trino/test_multihop_joined_plan__ep_0.xml @@ -8,7 +8,7 @@ - + @@ -28,14 +28,14 @@ - + - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index c643d94092..e98b83b46b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS FLOAT64) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY ds__day , listing__country_latest - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter - , DATETIME_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_10 - ) subq_11 - ) subq_12 + 1 AS views + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter + , DATETIME_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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY ds__day , listing__country_latest - ) subq_18 - ) subq_19 + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.ds__day ) GROUP BY ds__day , listing__country_latest -) subq_20 +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 89de78b140..5c1257ec0b 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY ds__day , listing__country_latest - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY ds__day , listing__country_latest - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.ds__day ) GROUP BY ds__day , listing__country_latest -) subq_41 +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index c59a914110..8e2a3ae1f4 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS DOUBLE) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_6.ds__day + , subq_6.listing__country_latest + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_10 - ) subq_11 - ) subq_12 + 1 AS views + , 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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_15.ds__day + , subq_15.listing__country_latest + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.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_8.ds__day, subq_17.ds__day) + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 67be9580e0..3d343d6be9 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day + subq_20.ds__day , listings_latest_src_28000.country - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day + subq_29.ds__day , listings_latest_src_28000.country - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.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_27.ds__day, subq_36.ds__day) + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 0faa937f47..99b5b1a2b3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_6.ds__day + , subq_6.listing__country_latest + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_10 - ) subq_11 - ) subq_12 + 1 AS views + , 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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_15.ds__day + , subq_15.listing__country_latest + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.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_8.ds__day, subq_17.ds__day) + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 4194a63b3f..df63e3cc3d 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day + subq_20.ds__day , listings_latest_src_28000.country - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day + subq_29.ds__day , listings_latest_src_28000.country - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.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_27.ds__day, subq_36.ds__day) + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index f5832b8060..2aafc00ba7 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_6.ds__day + , subq_6.listing__country_latest + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_10 - ) subq_11 - ) subq_12 + 1 AS views + , 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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_15.ds__day + , subq_15.listing__country_latest + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.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_8.ds__day, subq_17.ds__day) + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 4194a63b3f..df63e3cc3d 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day + subq_20.ds__day , listings_latest_src_28000.country - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day + subq_29.ds__day , listings_latest_src_28000.country - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.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_27.ds__day, subq_36.ds__day) + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index cfc49a14d2..21ba122a90 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS DOUBLE) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_6.ds__day + , subq_6.listing__country_latest + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_10 - ) subq_11 - ) subq_12 + 1 AS views + , 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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_15.ds__day + , subq_15.listing__country_latest + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.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_8.ds__day, subq_17.ds__day) + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 67be9580e0..3d343d6be9 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day + subq_20.ds__day , listings_latest_src_28000.country - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day + subq_29.ds__day , listings_latest_src_28000.country - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.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_27.ds__day, subq_36.ds__day) + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index a00d94921e..4d4c508b4a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -1,317 +1,405 @@ -- 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_18.ds__day + , subq_18.listing__country_latest + , CAST(subq_18.bookings AS DOUBLE) / CAST(NULLIF(subq_18.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_8.ds__day, subq_17.ds__day) AS ds__day + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_17.views) AS views FROM ( -- Compute Metrics via Expressions SELECT - subq_8.ds__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_7.ds__day + , subq_7.listing__country_latest + , subq_7.bookings FROM ( -- Aggregate Measures SELECT - subq_7.ds__day - , subq_7.listing__country_latest - , SUM(subq_7.bookings) AS bookings + subq_6.ds__day + , subq_6.listing__country_latest + , SUM(subq_6.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_5.ds__day + , subq_5.listing__country_latest + , subq_5.bookings FROM ( -- Join Standard Outputs SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.ds__day AS ds__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_4.listing - , subq_4.country_latest + subq_3.listing + , subq_3.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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -372,243 +460,293 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + subq_1.listing = subq_4.listing + ) subq_5 + ) subq_6 GROUP BY - subq_7.ds__day - , subq_7.listing__country_latest - ) subq_8 - ) subq_9 + subq_6.ds__day + , subq_6.listing__country_latest + ) subq_7 + ) subq_8 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_18.ds__day - , subq_18.listing__country_latest - , subq_18.views + subq_16.ds__day + , subq_16.listing__country_latest + , subq_16.views FROM ( -- Aggregate Measures SELECT - subq_17.ds__day - , subq_17.listing__country_latest - , SUM(subq_17.views) AS views + subq_15.ds__day + , subq_15.listing__country_latest + , SUM(subq_15.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_14.ds__day + , subq_14.listing__country_latest + , subq_14.views FROM ( -- Join Standard Outputs SELECT - subq_15.country_latest AS listing__country_latest - , subq_12.ds__day AS ds__day - , subq_12.listing AS listing - , subq_12.views AS views + subq_13.country_latest AS listing__country_latest + , 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.view__ds__day AS view__ds__day + , subq_10.view__ds__week AS view__ds__week + , subq_10.view__ds__month AS view__ds__month + , subq_10.view__ds__quarter AS view__ds__quarter + , subq_10.view__ds__year AS view__ds__year + , subq_10.view__ds__extract_year AS view__ds__extract_year + , subq_10.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_10.view__ds__extract_month AS view__ds__extract_month + , subq_10.view__ds__extract_day AS view__ds__extract_day + , subq_10.view__ds__extract_dow AS view__ds__extract_dow + , subq_10.view__ds__extract_doy AS view__ds__extract_doy + , subq_10.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_10.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_10.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_10.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_10.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_10.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_10.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_10.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_10.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_10.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_10.view__ds_partitioned__extract_doy AS view__ds_partitioned__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.user AS user + , subq_10.view__listing AS view__listing + , subq_10.view__user AS view__user + , subq_10.views AS views FROM ( - -- Pass Only Elements: ['views', 'ds__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.listing - , subq_11.views + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_partitioned__day + , subq_9.ds_partitioned__week + , subq_9.ds_partitioned__month + , subq_9.ds_partitioned__quarter + , subq_9.ds_partitioned__year + , subq_9.ds_partitioned__extract_year + , subq_9.ds_partitioned__extract_quarter + , subq_9.ds_partitioned__extract_month + , subq_9.ds_partitioned__extract_day + , subq_9.ds_partitioned__extract_dow + , subq_9.ds_partitioned__extract_doy + , subq_9.view__ds__day + , subq_9.view__ds__week + , subq_9.view__ds__month + , subq_9.view__ds__quarter + , subq_9.view__ds__year + , subq_9.view__ds__extract_year + , subq_9.view__ds__extract_quarter + , subq_9.view__ds__extract_month + , subq_9.view__ds__extract_day + , subq_9.view__ds__extract_dow + , subq_9.view__ds__extract_doy + , subq_9.view__ds_partitioned__day + , subq_9.view__ds_partitioned__week + , subq_9.view__ds_partitioned__month + , subq_9.view__ds_partitioned__quarter + , subq_9.view__ds_partitioned__year + , subq_9.view__ds_partitioned__extract_year + , subq_9.view__ds_partitioned__extract_quarter + , subq_9.view__ds_partitioned__extract_month + , subq_9.view__ds_partitioned__extract_day + , subq_9.view__ds_partitioned__extract_dow + , subq_9.view__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.listing + , subq_9.user + , subq_9.view__listing + , subq_9.view__user + , subq_9.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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 - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_10 - ) subq_11 - ) subq_12 + 1 AS views + , 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_9 + ) subq_10 LEFT OUTER JOIN ( -- Pass Only Elements: ['country_latest', 'listing'] SELECT - subq_14.listing - , subq_14.country_latest + subq_12.listing + , subq_12.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_11.ds__day + , subq_11.ds__week + , subq_11.ds__month + , subq_11.ds__quarter + , subq_11.ds__year + , subq_11.ds__extract_year + , subq_11.ds__extract_quarter + , subq_11.ds__extract_month + , subq_11.ds__extract_day + , subq_11.ds__extract_dow + , subq_11.ds__extract_doy + , subq_11.created_at__day + , subq_11.created_at__week + , subq_11.created_at__month + , subq_11.created_at__quarter + , subq_11.created_at__year + , subq_11.created_at__extract_year + , subq_11.created_at__extract_quarter + , subq_11.created_at__extract_month + , subq_11.created_at__extract_day + , subq_11.created_at__extract_dow + , subq_11.created_at__extract_doy + , subq_11.listing__ds__day + , subq_11.listing__ds__week + , subq_11.listing__ds__month + , subq_11.listing__ds__quarter + , subq_11.listing__ds__year + , subq_11.listing__ds__extract_year + , subq_11.listing__ds__extract_quarter + , subq_11.listing__ds__extract_month + , subq_11.listing__ds__extract_day + , subq_11.listing__ds__extract_dow + , subq_11.listing__ds__extract_doy + , subq_11.listing__created_at__day + , subq_11.listing__created_at__week + , subq_11.listing__created_at__month + , subq_11.listing__created_at__quarter + , subq_11.listing__created_at__year + , subq_11.listing__created_at__extract_year + , subq_11.listing__created_at__extract_quarter + , subq_11.listing__created_at__extract_month + , subq_11.listing__created_at__extract_day + , subq_11.listing__created_at__extract_dow + , subq_11.listing__created_at__extract_doy + , subq_11.ds__day AS metric_time__day + , subq_11.ds__week AS metric_time__week + , subq_11.ds__month AS metric_time__month + , subq_11.ds__quarter AS metric_time__quarter + , subq_11.ds__year AS metric_time__year + , subq_11.ds__extract_year AS metric_time__extract_year + , subq_11.ds__extract_quarter AS metric_time__extract_quarter + , subq_11.ds__extract_month AS metric_time__extract_month + , subq_11.ds__extract_day AS metric_time__extract_day + , subq_11.ds__extract_dow AS metric_time__extract_dow + , subq_11.ds__extract_doy AS metric_time__extract_doy + , subq_11.listing + , subq_11.user + , subq_11.listing__user + , subq_11.country_latest + , subq_11.is_lux_latest + , subq_11.capacity_latest + , subq_11.listing__country_latest + , subq_11.listing__is_lux_latest + , subq_11.listing__capacity_latest + , subq_11.listings + , subq_11.largest_listing + , subq_11.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -669,25 +807,25 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_13 - ) subq_14 - ) subq_15 + ) subq_11 + ) subq_12 + ) subq_13 ON - subq_12.listing = subq_15.listing - ) subq_16 - ) subq_17 + subq_10.listing = subq_13.listing + ) subq_14 + ) subq_15 GROUP BY - subq_17.ds__day - , subq_17.listing__country_latest - ) subq_18 - ) subq_19 + subq_15.ds__day + , subq_15.listing__country_latest + ) subq_16 + ) subq_17 ON ( - subq_9.listing__country_latest = subq_19.listing__country_latest + subq_8.listing__country_latest = subq_17.listing__country_latest ) AND ( - subq_9.ds__day = subq_19.ds__day + subq_8.ds__day = subq_17.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_8.ds__day, subq_17.ds__day) + , COALESCE(subq_8.listing__country_latest, subq_17.listing__country_latest) +) subq_18 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 67be9580e0..3d343d6be9 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -6,71 +6,69 @@ 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_27.ds__day, subq_36.ds__day) AS ds__day + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) AS listing__country_latest + , MAX(subq_27.bookings) AS bookings + , MAX(subq_36.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 + subq_20.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + , SUM(subq_20.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_23.listing = listings_latest_src_28000.listing_id + subq_20.listing = listings_latest_src_28000.listing_id GROUP BY - subq_23.ds__day + subq_20.ds__day , listings_latest_src_28000.country - ) subq_30 + ) subq_27 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 + subq_29.ds__day AS ds__day , listings_latest_src_28000.country AS listing__country_latest - , SUM(subq_33.views) AS views + , SUM(subq_29.views) AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'ds__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_33 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_33.listing = listings_latest_src_28000.listing_id + subq_29.listing = listings_latest_src_28000.listing_id GROUP BY - subq_33.ds__day + subq_29.ds__day , listings_latest_src_28000.country - ) subq_40 + ) subq_36 ON ( - subq_30.listing__country_latest = subq_40.listing__country_latest + subq_27.listing__country_latest = subq_36.listing__country_latest ) AND ( - subq_30.ds__day = subq_40.ds__day + subq_27.ds__day = subq_36.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_27.ds__day, subq_36.ds__day) + , COALESCE(subq_27.listing__country_latest, subq_36.listing__country_latest) +) subq_37 diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index d46d963d11..35bcd3afd3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -1,17 +1,17 @@ - - + + - + - + - + @@ -32,11 +32,11 @@ - + - - + + @@ -54,25 +54,25 @@ - - + + - + - - + + - + - + - + @@ -80,1387 +80,1837 @@ - + - + - + - + - + - + - - + + - + - + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - - - - + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + + + + + + + + + + - + @@ -1767,25 +2217,25 @@ - - + + - + - - + + - + - + - + @@ -1793,1002 +2243,1262 @@ - + - + - + - + - + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + - + + + + + + + + + + + + + - + - + - - + + - - + + - + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 2076a0ccf1..58b7761be3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON DATE_SUB(CAST(subq_5.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_9 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index b50ea33e0f..dc3b2de622 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 8a5180f7c6..fec1f47c91 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON DATE_SUB(CAST(subq_8.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index de4960ffcf..c67bfc361f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON DATE_SUB(CAST(subq_25.ds AS DATETIME), INTERVAL 14 day) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql index 1a77e87eff..fd7b4bc750 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 2ecd5d35b3..ff910ed74f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week - , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month - , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter - , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow - , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ON - DATETIME_TRUNC(subq_2.metric_time__day, month) = subq_1.metric_time__day - WHERE DATETIME_TRUNC(subq_2.metric_time__day, month) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 + ON + DATETIME_TRUNC(subq_2.metric_time__day, month) = subq_1.metric_time__day + WHERE DATETIME_TRUNC(subq_2.metric_time__day, month) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY metric_time__month - ) subq_8 -) subq_9 + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index cdef6c0de0..b07614dc14 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATETIME_TRUNC(subq_13.ds, month) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATETIME_TRUNC(subq_12.ds, month) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATETIME_TRUNC(subq_13.ds, month) = subq_11.metric_time__day - WHERE DATETIME_TRUNC(subq_13.ds, month) = subq_13.ds - ) subq_15 + DATETIME_TRUNC(subq_12.ds, month) = subq_10.metric_time__day + WHERE DATETIME_TRUNC(subq_12.ds, month) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 663ef82bce..255d195524 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATETIME_TRUNC(subq_2.metric_time__day, isoweek) AS metric_time__week - , DATETIME_TRUNC(subq_2.metric_time__day, month) AS metric_time__month - , DATETIME_TRUNC(subq_2.metric_time__day, quarter) AS metric_time__quarter - , DATETIME_TRUNC(subq_2.metric_time__day, year) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , IF(EXTRACT(dayofweek FROM subq_2.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_2.metric_time__day) - 1) AS metric_time__extract_dow - , EXTRACT(dayofyear FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ON - DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 1 week) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 1 week) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY metric_time__month - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY metric_time__month -) subq_17 +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index 31f0a39d91..56b0a42d94 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATETIME_TRUNC(subq_21.ds, month) AS metric_time__month + subq_19.ds AS metric_time__day + , DATETIME_TRUNC(subq_19.ds, month) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_SUB(CAST(subq_21.ds AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) - ) subq_23 + DATE_SUB(CAST(subq_19.ds AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, month) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY metric_time__month -) subq_35 +) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 649b310687..827ae7eeff 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_9 GROUP BY subq_9.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..ff652eccbf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index e7137cfe83..6d6173f882 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY subq_3.metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..126872efb8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql index 37c4e4c813..0e5e489290 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 4111729e97..bc1cdcecdc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day + WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.metric_time__month - ) subq_8 -) subq_9 + subq_6.metric_time__month + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..324d26cfec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds - ) subq_15 + DATE_TRUNC('month', subq_12.ds) = subq_10.metric_time__day + WHERE DATE_TRUNC('month', subq_12.ds) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 04e5e6ec5e..97c146cbeb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + subq_6.metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_9 + ) subq_10 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY - subq_14.metric_time__month - ) subq_15 - ) subq_16 + subq_12.metric_time__month + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) -) subq_17 + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..40dda13956 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) - ) subq_23 + DATEADD(week, -1, subq_19.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) -) subq_35 + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) +) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 7922d7265d..12fc0660dd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON subq_5.metric_time__day - MAKE_INTERVAL(days => 2) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_9 GROUP BY subq_9.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index e59b680106..24ee4c630c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 0fd450ec32..a184f51ca9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY subq_3.metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON subq_8.metric_time__day - MAKE_INTERVAL(days => 14) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 9a52bdd33f..d5bb9dafff 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON subq_25.ds - MAKE_INTERVAL(days => 14) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql index 1cb582d6b5..3e2f1a6361 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index c633e0a0db..5f3940635c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day + WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.metric_time__month - ) subq_8 -) subq_9 + subq_6.metric_time__month + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..324d26cfec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds - ) subq_15 + DATE_TRUNC('month', subq_12.ds) = subq_10.metric_time__day + WHERE DATE_TRUNC('month', subq_12.ds) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 6c5dc6b093..77b515c67d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(isodow FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - subq_2.metric_time__day - MAKE_INTERVAL(weeks => 1) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + subq_2.metric_time__day - MAKE_INTERVAL(weeks => 1) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + subq_6.metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_9 + ) subq_10 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY - subq_14.metric_time__month - ) subq_15 - ) subq_16 + subq_12.metric_time__month + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) -) subq_17 + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index f83880110c..8ee9b37ab4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - subq_21.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) - ) subq_23 + subq_19.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) -) subq_35 + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) +) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 946587cdba..4d69a03994 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_9 GROUP BY subq_9.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..ff652eccbf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 2838e435a1..93b4d660d8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY subq_3.metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..126872efb8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql index 57d207544d..8ae8ed0bb6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 9b7c4b2bef..de04cbafed 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day + WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.metric_time__month - ) subq_8 -) subq_9 + subq_6.metric_time__month + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..324d26cfec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds - ) subq_15 + DATE_TRUNC('month', subq_12.ds) = subq_10.metric_time__day + WHERE DATE_TRUNC('month', subq_12.ds) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 796a8201a6..4dd9a7cb3f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , CASE WHEN EXTRACT(dow FROM subq_2.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_2.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_2.metric_time__day) END AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + subq_6.metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_9 + ) subq_10 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY - subq_14.metric_time__month - ) subq_15 - ) subq_16 + subq_12.metric_time__month + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) -) subq_17 + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..40dda13956 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) - ) subq_23 + DATEADD(week, -1, subq_19.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) -) subq_35 + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) +) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 306fc5aa5f..010e0ae076 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON DATEADD(day, -2, subq_5.metric_time__day) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN '2019-12-19' AND '2020-01-02' ) subq_9 GROUP BY subq_9.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..ff652eccbf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 47ad965ef1..454fce5a44 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY subq_3.metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON DATEADD(day, -14, subq_8.metric_time__day) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..126872efb8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql index 4bd8517da5..cead3aab72 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 24810fdc57..874baf9232 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day + WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.metric_time__month - ) subq_8 -) subq_9 + subq_6.metric_time__month + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..324d26cfec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds - ) subq_15 + DATE_TRUNC('month', subq_12.ds) = subq_10.metric_time__day + WHERE DATE_TRUNC('month', subq_12.ds) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 09bf3b33db..59fcf0f2ce 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(dayofweekiso FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + DATEADD(week, -1, subq_2.metric_time__day) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + subq_6.metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_9 + ) subq_10 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY - subq_14.metric_time__month - ) subq_15 - ) subq_16 + subq_12.metric_time__month + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) -) subq_17 + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..40dda13956 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) - ) subq_23 + DATEADD(week, -1, subq_19.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) -) subq_35 + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) +) subq_31 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index ff9b7c69df..3d30faf3d2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -13,15 +13,111 @@ FROM ( subq_9.metric_time__day , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT subq_8.metric_time__day , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__day'] + -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] SELECT 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.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.listing + , subq_7.guest + , subq_7.host + , subq_7.booking__listing + , subq_7.booking__guest + , subq_7.booking__host + , subq_7.is_instant + , subq_7.booking__is_instant + , subq_7.bookings + , subq_7.instant_bookings + , subq_7.booking_value + , subq_7.max_booking_value + , subq_7.min_booking_value , subq_7.bookers + , subq_7.average_booking_value + , subq_7.referred_bookings + , subq_7.median_booking_value + , subq_7.booking_value_p99 + , subq_7.discrete_booking_value_p99 + , subq_7.approximate_continuous_booking_value_p99 + , subq_7.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -442,8 +538,8 @@ FROM ( ON DATE_ADD('day', -2, subq_5.metric_time__day) = subq_4.metric_time__day ) subq_7 + WHERE subq_7.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' ) subq_8 - WHERE subq_8.metric_time__day BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' ) subq_9 GROUP BY subq_9.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 1a9dc9da62..386c6b7f41 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -4,8 +4,8 @@ SELECT , every_2_days_bookers_2_days_ago AS every_2_days_bookers_2_days_ago FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Constrain Time Range to [2019-12-19T00:00:00, 2020-01-02T00:00:00] + -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 6cbd2d5ff1..76d85a97ae 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -19,15 +19,111 @@ FROM ( subq_3.metric_time__day , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -223,8 +319,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_2 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_3 GROUP BY subq_3.metric_time__day @@ -241,15 +337,111 @@ FROM ( subq_12.metric_time__day , SUM(subq_12.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT subq_11.metric_time__day , subq_11.bookings FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day'] + -- Constrain Output with WHERE SELECT subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Join to Time Spine Dataset SELECT @@ -555,8 +747,8 @@ FROM ( ON DATE_ADD('day', -14, subq_8.metric_time__day) = subq_7.metric_time__day ) subq_10 + WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_11 - WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' ) subq_12 GROUP BY subq_12.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 9cf94d7fbc..d68ebf6965 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -10,6 +10,7 @@ FROM ( , MAX(subq_30.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -18,18 +19,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_18 + ) subq_17 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day ) subq_21 FULL OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'metric_time__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -37,7 +38,6 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago 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 @@ -52,7 +52,7 @@ FROM ( ) subq_23 ON DATE_ADD('day', -14, subq_25.ds) = subq_23.metric_time__day - ) subq_27 + ) subq_26 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql index c903d27c87..f5bab3511c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0.sql @@ -8,892 +8,883 @@ 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_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_25.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.average_booking_value + subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - AVG(subq_9.average_booking_value) AS average_booking_value + AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value',] SELECT - subq_8.average_booking_value + subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'listing'] - SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_8 - ) subq_9 - ) subq_10 - ) subq_11 - CROSS JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.bookings - FROM ( - -- Aggregate Measures - SELECT - SUM(subq_21.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings',] - SELECT - subq_20.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_19.booking__is_instant - , subq_19.listing__is_lux_latest - , subq_19.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 - FROM ( - -- Join Standard Outputs + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.listing AS listing - , subq_14.booking__is_instant AS booking__is_instant - , subq_14.bookings AS bookings + subq_3.listing + , subq_3.is_lux_latest FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_13.listing - , subq_13.booking__is_instant - , subq_13.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] - SELECT - subq_16.listing - , subq_16.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_20 - ) subq_21 - ) subq_22 - ) subq_23 + ) subq_6 + ) subq_7 + ) subq_8 + ) subq_9 CROSS JOIN ( -- Compute Metrics via Expressions SELECT - subq_29.booking_value + subq_18.bookings FROM ( -- Aggregate Measures SELECT - SUM(subq_28.booking_value) AS booking_value + SUM(subq_17.bookings) AS bookings FROM ( - -- Pass Only Elements: ['booking_value',] + -- Pass Only Elements: ['bookings',] SELECT - subq_27.booking_value + subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_26.booking__is_instant - , subq_26.booking_value + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_25.booking__is_instant - , subq_25.booking_value + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 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_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -986,13 +977,466 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (booking__is_instant) + ) subq_16 + ) subq_17 + ) subq_18 + ) subq_19 + CROSS JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_24.booking_value + FROM ( + -- Aggregate Measures + SELECT + SUM(subq_23.booking_value) AS booking_value + FROM ( + -- Pass Only Elements: ['booking_value',] + SELECT + subq_22.booking_value + FROM ( + -- Constrain Output with WHERE + SELECT + 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.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.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 ( + -- Metric Time Dimension 'ds' + SELECT + subq_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_20 + ) subq_21 WHERE booking__is_instant - ) subq_27 - ) subq_28 - ) subq_29 - ) subq_30 - ) subq_31 -) subq_32 + ) subq_22 + ) subq_23 + ) subq_24 + ) subq_25 + ) subq_26 +) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql index 587ebb6267..bceaae3fc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_filters__plan0_optimized.sql @@ -8,9 +8,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - MAX(subq_44.average_booking_value) AS average_booking_value - , MAX(subq_44.bookings) AS bookings - , MAX(subq_51.booking_value) AS booking_value + MAX(subq_37.average_booking_value) AS average_booking_value + , MAX(subq_37.bookings) AS bookings + , MAX(subq_43.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings'] @@ -21,30 +21,28 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'booking__is_instant'] SELECT - subq_35.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_35.bookings AS bookings - , subq_35.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_29.booking__is_instant AS booking__is_instant + , subq_29.bookings AS bookings + , subq_29.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_35 + ) subq_29 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_35.listing = listings_latest_src_28000.listing_id - ) subq_40 + subq_29.listing = listings_latest_src_28000.listing_id + ) subq_33 WHERE (listing__is_lux_latest) AND (booking__is_instant) - ) subq_44 + ) subq_37 CROSS JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value',] @@ -55,13 +53,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant'] SELECT is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_47 + ) subq_39 WHERE booking__is_instant - ) subq_51 - ) subq_52 -) subq_53 + ) subq_43 + ) subq_44 +) subq_45 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 26bb799b98..efca4b065f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,345 +1,433 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__month + subq_8.metric_time__month , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.bookings AS bookings_start_of_month + subq_7.metric_time__month + , subq_7.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.bookings) AS bookings + subq_6.metric_time__month + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.bookings + subq_5.metric_time__month + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.bookings + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.bookings + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - INNER JOIN ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day - ) subq_4 - ) subq_5 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day + WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + ) subq_4 WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.metric_time__month - ) subq_8 -) subq_9 + subq_6.metric_time__month + ) subq_7 +) subq_8 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..324d26cfec 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -12,12 +12,11 @@ FROM ( , SUM(bookings) AS bookings_start_of_month FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month - , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month + , subq_10.bookings AS bookings + FROM ***************************.mf_time_spine subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -25,12 +24,12 @@ FROM ( DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds - ) subq_15 + DATE_TRUNC('month', subq_12.ds) = subq_10.metric_time__day + WHERE DATE_TRUNC('month', subq_12.ds) = subq_12.ds + ) subq_13 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month -) subq_19 +) subq_17 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 119f12fed2..8e231fa1df 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -1,481 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_17.metric_time__month + subq_15.metric_time__month , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) AS metric_time__month - , MAX(subq_9.booking_value) AS booking_value - , MAX(subq_16.bookers) AS bookers + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) AS metric_time__month + , MAX(subq_8.booking_value) AS booking_value + , MAX(subq_14.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month - , subq_8.booking_value + subq_7.metric_time__month + , subq_7.booking_value FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month - , SUM(subq_7.booking_value) AS booking_value + subq_6.metric_time__month + , SUM(subq_6.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__month'] SELECT - subq_6.metric_time__month - , subq_6.booking_value + subq_5.metric_time__month + , subq_5.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_5.metric_time__day - , subq_5.metric_time__month - , subq_5.booking_value + subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.max_booking_value + , subq_4.min_booking_value + , subq_4.bookers + , subq_4.average_booking_value + , subq_4.referred_bookings + , subq_4.median_booking_value + , subq_4.booking_value_p99 + , subq_4.discrete_booking_value_p99 + , subq_4.approximate_continuous_booking_value_p99 + , subq_4.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] + -- Join to Time Spine Dataset SELECT - subq_4.metric_time__day - , subq_4.metric_time__month - , subq_4.booking_value + subq_2.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy + , 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 FROM ( - -- Join to Time Spine Dataset + -- Time Spine SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_2.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_2.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_2.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_2.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_2.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_2.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_2.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_2.metric_time__day) AS metric_time__extract_doy - , 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - DATE_ADD('week', -1, subq_2.metric_time__day) = subq_1.metric_time__day - ) subq_4 - ) subq_5 - WHERE metric_time__day = '2020-01-01' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.metric_time__month - ) subq_8 - ) subq_9 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_15.metric_time__month - , subq_15.bookers - FROM ( - -- Aggregate Measures - SELECT - subq_14.metric_time__month - , COUNT(DISTINCT subq_14.bookers) AS bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month'] - SELECT - subq_13.metric_time__month - , subq_13.bookers - FROM ( - -- Constrain Output with WHERE - SELECT - subq_12.metric_time__day - , subq_12.metric_time__month - , subq_12.bookers - FROM ( - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] - SELECT - subq_11.metric_time__day - , subq_11.metric_time__month - , subq_11.bookers - FROM ( + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + INNER JOIN ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.ds_partitioned__day - , subq_10.ds_partitioned__week - , subq_10.ds_partitioned__month - , subq_10.ds_partitioned__quarter - , subq_10.ds_partitioned__year - , subq_10.ds_partitioned__extract_year - , subq_10.ds_partitioned__extract_quarter - , subq_10.ds_partitioned__extract_month - , subq_10.ds_partitioned__extract_day - , subq_10.ds_partitioned__extract_dow - , subq_10.ds_partitioned__extract_doy - , subq_10.paid_at__day - , subq_10.paid_at__week - , subq_10.paid_at__month - , subq_10.paid_at__quarter - , subq_10.paid_at__year - , subq_10.paid_at__extract_year - , subq_10.paid_at__extract_quarter - , subq_10.paid_at__extract_month - , subq_10.paid_at__extract_day - , subq_10.paid_at__extract_dow - , subq_10.paid_at__extract_doy - , subq_10.booking__ds__day - , subq_10.booking__ds__week - , subq_10.booking__ds__month - , subq_10.booking__ds__quarter - , subq_10.booking__ds__year - , subq_10.booking__ds__extract_year - , subq_10.booking__ds__extract_quarter - , subq_10.booking__ds__extract_month - , subq_10.booking__ds__extract_day - , subq_10.booking__ds__extract_dow - , subq_10.booking__ds__extract_doy - , subq_10.booking__ds_partitioned__day - , subq_10.booking__ds_partitioned__week - , subq_10.booking__ds_partitioned__month - , subq_10.booking__ds_partitioned__quarter - , subq_10.booking__ds_partitioned__year - , subq_10.booking__ds_partitioned__extract_year - , subq_10.booking__ds_partitioned__extract_quarter - , subq_10.booking__ds_partitioned__extract_month - , subq_10.booking__ds_partitioned__extract_day - , subq_10.booking__ds_partitioned__extract_dow - , subq_10.booking__ds_partitioned__extract_doy - , subq_10.booking__paid_at__day - , subq_10.booking__paid_at__week - , subq_10.booking__paid_at__month - , subq_10.booking__paid_at__quarter - , subq_10.booking__paid_at__year - , subq_10.booking__paid_at__extract_year - , subq_10.booking__paid_at__extract_quarter - , subq_10.booking__paid_at__extract_month - , subq_10.booking__paid_at__extract_day - , subq_10.booking__paid_at__extract_dow - , subq_10.booking__paid_at__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.listing - , subq_10.guest - , subq_10.host - , subq_10.booking__listing - , subq_10.booking__guest - , subq_10.booking__host - , subq_10.is_instant - , subq_10.booking__is_instant - , subq_10.bookings - , subq_10.instant_bookings - , subq_10.booking_value - , subq_10.max_booking_value - , subq_10.min_booking_value - , subq_10.bookers - , subq_10.average_booking_value - , subq_10.referred_bookings - , subq_10.median_booking_value - , subq_10.booking_value_p99 - , subq_10.discrete_booking_value_p99 - , subq_10.approximate_continuous_booking_value_p99 - , subq_10.approximate_discrete_booking_value_p99 + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -568,18 +424,338 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_10 - ) subq_11 - ) subq_12 + ) subq_0 + ) subq_1 + ON + DATE_ADD('week', -1, subq_2.metric_time__day) = subq_1.metric_time__day + ) subq_4 + WHERE metric_time__day = '2020-01-01' + ) subq_5 + ) subq_6 + GROUP BY + subq_6.metric_time__month + ) subq_7 + ) subq_8 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_13.metric_time__month + , subq_13.bookers + FROM ( + -- Aggregate Measures + SELECT + subq_12.metric_time__month + , COUNT(DISTINCT subq_12.bookers) AS bookers + FROM ( + -- Pass Only Elements: ['bookers', 'metric_time__month'] + SELECT + subq_11.metric_time__month + , subq_11.bookers + FROM ( + -- Constrain Output with WHERE + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 + FROM ( + -- 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 + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + SELECT + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_9 + ) subq_10 WHERE metric_time__day = '2020-01-01' - ) subq_13 - ) subq_14 + ) subq_11 + ) subq_12 GROUP BY - subq_14.metric_time__month - ) subq_15 - ) subq_16 + subq_12.metric_time__month + ) subq_13 + ) subq_14 ON - subq_9.metric_time__month = subq_16.metric_time__month + subq_8.metric_time__month = subq_14.metric_time__month GROUP BY - COALESCE(subq_9.metric_time__month, subq_16.metric_time__month) -) subq_17 + COALESCE(subq_8.metric_time__month, subq_14.metric_time__month) +) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index 5b548d42a9..66e288eead 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) AS metric_time__month - , MAX(subq_27.booking_value) AS booking_value - , MAX(subq_34.bookers) AS bookers + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) AS metric_time__month + , MAX(subq_24.booking_value) AS booking_value + , MAX(subq_30.bookers) AS bookers FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__month'] @@ -18,21 +18,20 @@ FROM ( , SUM(booking_value) AS booking_value FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ***************************.mf_time_spine subq_19 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_ADD('week', -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) - ) subq_23 + DATE_ADD('week', -1, subq_19.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + ) subq_20 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_27 + ) subq_24 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookers', 'metric_time__month'] @@ -44,19 +43,18 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'metric_time__month', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_26 WHERE metric_time__day = '2020-01-01' GROUP BY metric_time__month - ) subq_34 + ) subq_30 ON - subq_27.metric_time__month = subq_34.metric_time__month + subq_24.metric_time__month = subq_30.metric_time__month GROUP BY - COALESCE(subq_27.metric_time__month, subq_34.metric_time__month) -) subq_35 + COALESCE(subq_24.metric_time__month, subq_30.metric_time__month) +) subq_31 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index af6d4cbd39..91f7def56a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATETIME_TRUNC(subq_7.ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATETIME_TRUNC(subq_6.ds, month) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 7476b99dc0..6a61a5f0b0 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATETIME_TRUNC(ds, month) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, month) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index cde81a727b..68c2999a30 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATETIME_TRUNC(subq_7.ds, month) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATETIME_TRUNC(subq_6.ds, month) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY booking__ds__day - ) subq_5 + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index 3df172d11a..1b12abe850 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATETIME_TRUNC(ds, month) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATETIME_TRUNC(ds, day) AS booking__ds__day , DATETIME_TRUNC(ds, month) AS booking__ds__month , DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 921864d85d..6c4db66318 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATETIME_TRUNC(subq_7.ds, month) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATETIME_TRUNC(subq_6.ds, month) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index d7a42d3b6d..215a1113d4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATETIME_TRUNC(ds, month) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATETIME_TRUNC(ds, month) AS booking__ds__month , DATETIME_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index f9d9003f73..c1fe8ab7b8 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,23 +1,23 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATETIME_TRUNC(subq_7.ts, day) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATETIME_TRUNC(subq_6.ts, day) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -25,414 +25,594 @@ FROM ( ) GROUP BY metric_time__day - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month - , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter - , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow - , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds, isoweek) AS user__ds__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds, month) AS user__ds__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds, quarter) AS user__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, day) AS user__created_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, isoweek) AS user__created_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, month) AS user__created_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.created_at, quarter) AS user__created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, isoweek) AS user__ds_partitioned__week + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, month) AS user__ds_partitioned__month + , DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, quarter) AS user__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, millisecond) AS user__last_profile_edit_ts__millisecond + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, second) AS user__last_profile_edit_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, minute) AS user__last_profile_edit_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, hour) AS user__last_profile_edit_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, day) AS user__last_profile_edit_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, isoweek) AS user__last_profile_edit_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, month) AS user__last_profile_edit_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, quarter) AS user__last_profile_edit_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_profile_edit_ts, year) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_profile_edit_ts) - 1) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, second) AS user__bio_added_ts__second + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, minute) AS user__bio_added_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, hour) AS user__bio_added_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, day) AS user__bio_added_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, isoweek) AS user__bio_added_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, month) AS user__bio_added_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, quarter) AS user__bio_added_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.bio_added_ts, year) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.bio_added_ts) - 1) AS user__bio_added_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, minute) AS user__last_login_ts__minute + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, hour) AS user__last_login_ts__hour + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, day) AS user__last_login_ts__day + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, isoweek) AS user__last_login_ts__week + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, month) AS user__last_login_ts__month + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, quarter) AS user__last_login_ts__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.last_login_ts, year) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.last_login_ts) - 1) AS user__last_login_ts__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, hour) AS user__archived_at__hour + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, day) AS user__archived_at__day + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, isoweek) AS user__archived_at__week + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, month) AS user__archived_at__month + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, quarter) AS user__archived_at__quarter + , DATETIME_TRUNC(users_ds_source_src_28000.archived_at, year) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , IF(EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) = 1, 7, EXTRACT(dayofweek FROM users_ds_source_src_28000.archived_at) - 1) AS user__archived_at__extract_dow + , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index b7555abc78..7b1927e1b5 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATETIME_TRUNC(ts, day) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATETIME_TRUNC(archived_at, hour) AS metric_time__hour , DATETIME_TRUNC(archived_at, day) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql index 8ac5173a38..adf60f365b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATETIME_TRUNC(subq_8.ds, isoweek) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATETIME_TRUNC(subq_7.ds, isoweek) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY metric_time__day - ) subq_6 + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql index 86d3aec6d8..e0c07ad935 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 891ff0a69d..e4d11688cf 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATE_TRUNC('month', subq_7.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATE_TRUNC('month', subq_6.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 617bf2dd6f..ede2d5b59a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 7c2f0396ad..34169a6cdb 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__day - ) subq_5 + subq_3.booking__ds__day + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index e56534fda8..d57f45890a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index f50e75a9ec..9649f6fe95 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index 4e58f175e1..1096450ee1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 1a1ceec45a..4c064814e2 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,438 +1,618 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATE_TRUNC('day', subq_7.ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATE_TRUNC('day', subq_6.ts) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( metric_time__day = '2020-01-01' ) GROUP BY - subq_8.metric_time__day - ) subq_6 + subq_7.metric_time__day + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 8e318e894d..57d1af7281 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATE_TRUNC('day', ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATE_TRUNC('hour', archived_at) AS metric_time__hour , DATE_TRUNC('day', archived_at) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql index be842ce51d..23f82cee04 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATE_TRUNC('week', subq_8.ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATE_TRUNC('week', subq_7.ds) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_4.metric_time__day + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql index b1969a0a3d..8caa1086da 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 6396714619..84912e54e1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATE_TRUNC('month', subq_7.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATE_TRUNC('month', subq_6.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 617bf2dd6f..ede2d5b59a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 6c4f72bffb..e9b1caba63 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__day - ) subq_5 + subq_3.booking__ds__day + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index e56534fda8..d57f45890a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 37cf4da45c..58c0fb4a2a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index 4e58f175e1..1096450ee1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 9c928c4dce..454271efac 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,438 +1,618 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATE_TRUNC('day', subq_7.ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATE_TRUNC('day', subq_6.ts) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( metric_time__day = '2020-01-01' ) GROUP BY - subq_8.metric_time__day - ) subq_6 + subq_7.metric_time__day + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(isodow FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 8e318e894d..57d1af7281 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATE_TRUNC('day', ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATE_TRUNC('hour', archived_at) AS metric_time__hour , DATE_TRUNC('day', archived_at) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql index 699f928d1f..af69da9b75 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATE_TRUNC('week', subq_8.ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATE_TRUNC('week', subq_7.ds) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_4.metric_time__day + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql index b1969a0a3d..8caa1086da 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 3d9a94c629..ebaadd08b0 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATE_TRUNC('month', subq_7.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATE_TRUNC('month', subq_6.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 617bf2dd6f..ede2d5b59a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index ac263ad3e4..bae7e0b487 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__day - ) subq_5 + subq_3.booking__ds__day + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index e56534fda8..d57f45890a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 7585a9c449..bbdd0d9930 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index 4e58f175e1..1096450ee1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 13a45844c3..b51298c86f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,438 +1,618 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATE_TRUNC('day', subq_7.ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATE_TRUNC('day', subq_6.ts) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( metric_time__day = '2020-01-01' ) GROUP BY - subq_8.metric_time__day - ) subq_6 + subq_7.metric_time__day + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_profile_edit_ts) END AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.bio_added_ts) END AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.last_login_ts) END AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , CASE WHEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) = 0 THEN EXTRACT(dow FROM users_ds_source_src_28000.archived_at) + 7 ELSE EXTRACT(dow FROM users_ds_source_src_28000.archived_at) END AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 8e318e894d..57d1af7281 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATE_TRUNC('day', ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATE_TRUNC('hour', archived_at) AS metric_time__hour , DATE_TRUNC('day', archived_at) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql index df8221fca4..e6052318bb 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATE_TRUNC('week', subq_8.ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATE_TRUNC('week', subq_7.ds) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_4.metric_time__day + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql index b1969a0a3d..8caa1086da 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 199838aef6..6ddf4121e0 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATE_TRUNC('month', subq_7.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATE_TRUNC('month', subq_6.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 617bf2dd6f..ede2d5b59a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 94206af5c9..3430ba3fbc 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__day - ) subq_5 + subq_3.booking__ds__day + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index e56534fda8..d57f45890a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index c8f64bc99d..94d6603f93 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index 4e58f175e1..1096450ee1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index f602351496..25ae31a561 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,438 +1,618 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATE_TRUNC('day', subq_7.ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATE_TRUNC('day', subq_6.ts) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( metric_time__day = '2020-01-01' ) GROUP BY - subq_8.metric_time__day - ) subq_6 + subq_7.metric_time__day + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(dayofweekiso FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 8e318e894d..57d1af7281 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATE_TRUNC('day', ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATE_TRUNC('hour', archived_at) AS metric_time__hour , DATE_TRUNC('day', archived_at) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql index 75ee14665f..f66d044522 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATE_TRUNC('week', subq_8.ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATE_TRUNC('week', subq_7.ds) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_4.metric_time__day + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql index b1969a0a3d..8caa1086da 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-03' AND '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN '2020-01-03' AND '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql index 428c67859c..7007805b6d 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - , DATE_TRUNC('month', subq_7.ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + , DATE_TRUNC('month', subq_6.ds) AS metric_time__month + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.metric_time__month - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.metric_time__month - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql index 617bf2dd6f..ede2d5b59a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( metric_time__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (metric_time__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql index 99502becd2..f6e5c9a28a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0.sql @@ -1,256 +1,342 @@ -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.booking__ds__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.booking__ds__day AS booking__ds__day - , subq_5.bookings AS bookings + subq_5.booking__ds__day AS booking__ds__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.booking__ds__day + subq_7.booking__ds__day FROM ( -- Time Spine SELECT - subq_7.ds AS booking__ds__day - , DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS booking__ds__day + , DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.booking__ds__day - , SUM(subq_4.bookings) AS bookings + subq_3.booking__ds__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__ds__day'] SELECT - subq_3.booking__ds__day - , subq_3.bookings + subq_2.booking__ds__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__day - , subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__day - , subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.booking__ds__day - ) subq_5 + subq_3.booking__ds__day + ) subq_4 ON - subq_6.booking__ds__day = subq_5.booking__ds__day -) subq_9 + subq_5.booking__ds__day = subq_4.booking__ds__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql index e56534fda8..d57f45890a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.booking__ds__day AS booking__ds__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.booking__ds__day AS booking__ds__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -13,14 +13,14 @@ FROM ( ds AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__ds__day'] @@ -31,17 +31,16 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__ds__day', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY booking__ds__day -) subq_15 +) subq_13 ON - subq_16.booking__ds__day = subq_15.booking__ds__day + subq_14.booking__ds__day = subq_13.booking__ds__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql index 37ea96e4a6..a156c69349 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0.sql @@ -1,253 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_8.metric_time__day + , subq_8.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - DATE_TRUNC('month', subq_7.ds) AS booking__ds__month - , subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + DATE_TRUNC('month', subq_6.ds) AS booking__ds__month + , subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.booking__ds__month - , subq_2.metric_time__day - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] + -- Metric Time Dimension 'ds' SELECT - subq_1.booking__ds__month - , subq_1.metric_time__day - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql index 4e58f175e1..1096450ee1 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.bookings AS bookings_join_to_time_spine_with_tiered_filters + subq_14.metric_time__day AS metric_time__day + , subq_13.bookings AS bookings_join_to_time_spine_with_tiered_filters FROM ( -- Filter Time Spine SELECT @@ -12,14 +12,14 @@ FROM ( SELECT DATE_TRUNC('month', ds) AS booking__ds__month , ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE ( metric_time__day <= '2020-01-02' ) AND ( booking__ds__month > '2020-01-01' ) -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -30,16 +30,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'booking__ds__month'] SELECT DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((metric_time__day >= '2020-01-02') AND (metric_time__day <= '2020-01-02')) AND (booking__ds__month > '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 2bf7a13538..a28d453417 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -1,438 +1,618 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.archived_users AS archived_users_join_to_time_spine + subq_8.metric_time__day + , subq_8.archived_users AS archived_users_join_to_time_spine FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.archived_users AS archived_users + subq_5.metric_time__day AS metric_time__day + , subq_4.archived_users AS archived_users FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ts AS metric_time__hour - , DATE_TRUNC('day', subq_7.ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_7 - ) subq_8 + subq_6.ts AS metric_time__hour + , DATE_TRUNC('day', subq_6.ts) AS metric_time__day + FROM ***************************.mf_time_spine_hour subq_6 + ) subq_7 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( metric_time__day = '2020-01-01' ) GROUP BY - subq_8.metric_time__day - ) subq_6 + subq_7.metric_time__day + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.archived_users) AS archived_users + subq_3.metric_time__day + , SUM(subq_3.archived_users) AS archived_users FROM ( -- Pass Only Elements: ['archived_users', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.archived_users + subq_2.metric_time__day + , subq_2.archived_users FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__hour - , subq_2.metric_time__day - , subq_2.archived_users + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.created_at__day + , subq_1.created_at__week + , subq_1.created_at__month + , subq_1.created_at__quarter + , subq_1.created_at__year + , subq_1.created_at__extract_year + , subq_1.created_at__extract_quarter + , subq_1.created_at__extract_month + , subq_1.created_at__extract_day + , subq_1.created_at__extract_dow + , subq_1.created_at__extract_doy + , subq_1.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.last_profile_edit_ts__millisecond + , subq_1.last_profile_edit_ts__second + , subq_1.last_profile_edit_ts__minute + , subq_1.last_profile_edit_ts__hour + , subq_1.last_profile_edit_ts__day + , subq_1.last_profile_edit_ts__week + , subq_1.last_profile_edit_ts__month + , subq_1.last_profile_edit_ts__quarter + , subq_1.last_profile_edit_ts__year + , subq_1.last_profile_edit_ts__extract_year + , subq_1.last_profile_edit_ts__extract_quarter + , subq_1.last_profile_edit_ts__extract_month + , subq_1.last_profile_edit_ts__extract_day + , subq_1.last_profile_edit_ts__extract_dow + , subq_1.last_profile_edit_ts__extract_doy + , subq_1.bio_added_ts__second + , subq_1.bio_added_ts__minute + , subq_1.bio_added_ts__hour + , subq_1.bio_added_ts__day + , subq_1.bio_added_ts__week + , subq_1.bio_added_ts__month + , subq_1.bio_added_ts__quarter + , subq_1.bio_added_ts__year + , subq_1.bio_added_ts__extract_year + , subq_1.bio_added_ts__extract_quarter + , subq_1.bio_added_ts__extract_month + , subq_1.bio_added_ts__extract_day + , subq_1.bio_added_ts__extract_dow + , subq_1.bio_added_ts__extract_doy + , subq_1.last_login_ts__minute + , subq_1.last_login_ts__hour + , subq_1.last_login_ts__day + , subq_1.last_login_ts__week + , subq_1.last_login_ts__month + , subq_1.last_login_ts__quarter + , subq_1.last_login_ts__year + , subq_1.last_login_ts__extract_year + , subq_1.last_login_ts__extract_quarter + , subq_1.last_login_ts__extract_month + , subq_1.last_login_ts__extract_day + , subq_1.last_login_ts__extract_dow + , subq_1.last_login_ts__extract_doy + , subq_1.archived_at__hour + , subq_1.archived_at__day + , subq_1.archived_at__week + , subq_1.archived_at__month + , subq_1.archived_at__quarter + , subq_1.archived_at__year + , subq_1.archived_at__extract_year + , subq_1.archived_at__extract_quarter + , subq_1.archived_at__extract_month + , subq_1.archived_at__extract_day + , subq_1.archived_at__extract_dow + , subq_1.archived_at__extract_doy + , subq_1.user__ds__day + , subq_1.user__ds__week + , subq_1.user__ds__month + , subq_1.user__ds__quarter + , subq_1.user__ds__year + , subq_1.user__ds__extract_year + , subq_1.user__ds__extract_quarter + , subq_1.user__ds__extract_month + , subq_1.user__ds__extract_day + , subq_1.user__ds__extract_dow + , subq_1.user__ds__extract_doy + , subq_1.user__created_at__day + , subq_1.user__created_at__week + , subq_1.user__created_at__month + , subq_1.user__created_at__quarter + , subq_1.user__created_at__year + , subq_1.user__created_at__extract_year + , subq_1.user__created_at__extract_quarter + , subq_1.user__created_at__extract_month + , subq_1.user__created_at__extract_day + , subq_1.user__created_at__extract_dow + , subq_1.user__created_at__extract_doy + , subq_1.user__ds_partitioned__day + , subq_1.user__ds_partitioned__week + , subq_1.user__ds_partitioned__month + , subq_1.user__ds_partitioned__quarter + , subq_1.user__ds_partitioned__year + , subq_1.user__ds_partitioned__extract_year + , subq_1.user__ds_partitioned__extract_quarter + , subq_1.user__ds_partitioned__extract_month + , subq_1.user__ds_partitioned__extract_day + , subq_1.user__ds_partitioned__extract_dow + , subq_1.user__ds_partitioned__extract_doy + , subq_1.user__last_profile_edit_ts__millisecond + , subq_1.user__last_profile_edit_ts__second + , subq_1.user__last_profile_edit_ts__minute + , subq_1.user__last_profile_edit_ts__hour + , subq_1.user__last_profile_edit_ts__day + , subq_1.user__last_profile_edit_ts__week + , subq_1.user__last_profile_edit_ts__month + , subq_1.user__last_profile_edit_ts__quarter + , subq_1.user__last_profile_edit_ts__year + , subq_1.user__last_profile_edit_ts__extract_year + , subq_1.user__last_profile_edit_ts__extract_quarter + , subq_1.user__last_profile_edit_ts__extract_month + , subq_1.user__last_profile_edit_ts__extract_day + , subq_1.user__last_profile_edit_ts__extract_dow + , subq_1.user__last_profile_edit_ts__extract_doy + , subq_1.user__bio_added_ts__second + , subq_1.user__bio_added_ts__minute + , subq_1.user__bio_added_ts__hour + , subq_1.user__bio_added_ts__day + , subq_1.user__bio_added_ts__week + , subq_1.user__bio_added_ts__month + , subq_1.user__bio_added_ts__quarter + , subq_1.user__bio_added_ts__year + , subq_1.user__bio_added_ts__extract_year + , subq_1.user__bio_added_ts__extract_quarter + , subq_1.user__bio_added_ts__extract_month + , subq_1.user__bio_added_ts__extract_day + , subq_1.user__bio_added_ts__extract_dow + , subq_1.user__bio_added_ts__extract_doy + , subq_1.user__last_login_ts__minute + , subq_1.user__last_login_ts__hour + , subq_1.user__last_login_ts__day + , subq_1.user__last_login_ts__week + , subq_1.user__last_login_ts__month + , subq_1.user__last_login_ts__quarter + , subq_1.user__last_login_ts__year + , subq_1.user__last_login_ts__extract_year + , subq_1.user__last_login_ts__extract_quarter + , subq_1.user__last_login_ts__extract_month + , subq_1.user__last_login_ts__extract_day + , subq_1.user__last_login_ts__extract_dow + , subq_1.user__last_login_ts__extract_doy + , subq_1.user__archived_at__hour + , subq_1.user__archived_at__day + , subq_1.user__archived_at__week + , subq_1.user__archived_at__month + , subq_1.user__archived_at__quarter + , subq_1.user__archived_at__year + , subq_1.user__archived_at__extract_year + , subq_1.user__archived_at__extract_quarter + , subq_1.user__archived_at__extract_month + , subq_1.user__archived_at__extract_day + , subq_1.user__archived_at__extract_dow + , subq_1.user__archived_at__extract_doy + , subq_1.metric_time__hour + , 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.home_state + , subq_1.user__home_state + , subq_1.archived_users FROM ( - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] + -- Metric Time Dimension 'archived_at' SELECT - subq_1.metric_time__hour - , subq_1.metric_time__day - , subq_1.archived_users + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__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.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.last_profile_edit_ts__millisecond + , subq_0.last_profile_edit_ts__second + , subq_0.last_profile_edit_ts__minute + , subq_0.last_profile_edit_ts__hour + , subq_0.last_profile_edit_ts__day + , subq_0.last_profile_edit_ts__week + , subq_0.last_profile_edit_ts__month + , subq_0.last_profile_edit_ts__quarter + , subq_0.last_profile_edit_ts__year + , subq_0.last_profile_edit_ts__extract_year + , subq_0.last_profile_edit_ts__extract_quarter + , subq_0.last_profile_edit_ts__extract_month + , subq_0.last_profile_edit_ts__extract_day + , subq_0.last_profile_edit_ts__extract_dow + , subq_0.last_profile_edit_ts__extract_doy + , subq_0.bio_added_ts__second + , subq_0.bio_added_ts__minute + , subq_0.bio_added_ts__hour + , subq_0.bio_added_ts__day + , subq_0.bio_added_ts__week + , subq_0.bio_added_ts__month + , subq_0.bio_added_ts__quarter + , subq_0.bio_added_ts__year + , subq_0.bio_added_ts__extract_year + , subq_0.bio_added_ts__extract_quarter + , subq_0.bio_added_ts__extract_month + , subq_0.bio_added_ts__extract_day + , subq_0.bio_added_ts__extract_dow + , subq_0.bio_added_ts__extract_doy + , subq_0.last_login_ts__minute + , subq_0.last_login_ts__hour + , subq_0.last_login_ts__day + , subq_0.last_login_ts__week + , subq_0.last_login_ts__month + , subq_0.last_login_ts__quarter + , subq_0.last_login_ts__year + , subq_0.last_login_ts__extract_year + , subq_0.last_login_ts__extract_quarter + , subq_0.last_login_ts__extract_month + , subq_0.last_login_ts__extract_day + , subq_0.last_login_ts__extract_dow + , subq_0.last_login_ts__extract_doy + , subq_0.archived_at__hour + , subq_0.archived_at__day + , subq_0.archived_at__week + , subq_0.archived_at__month + , subq_0.archived_at__quarter + , subq_0.archived_at__year + , subq_0.archived_at__extract_year + , subq_0.archived_at__extract_quarter + , subq_0.archived_at__extract_month + , subq_0.archived_at__extract_day + , subq_0.archived_at__extract_dow + , subq_0.archived_at__extract_doy + , subq_0.user__ds__day + , subq_0.user__ds__week + , subq_0.user__ds__month + , subq_0.user__ds__quarter + , subq_0.user__ds__year + , subq_0.user__ds__extract_year + , subq_0.user__ds__extract_quarter + , subq_0.user__ds__extract_month + , subq_0.user__ds__extract_day + , subq_0.user__ds__extract_dow + , subq_0.user__ds__extract_doy + , subq_0.user__created_at__day + , subq_0.user__created_at__week + , subq_0.user__created_at__month + , subq_0.user__created_at__quarter + , subq_0.user__created_at__year + , subq_0.user__created_at__extract_year + , subq_0.user__created_at__extract_quarter + , subq_0.user__created_at__extract_month + , subq_0.user__created_at__extract_day + , subq_0.user__created_at__extract_dow + , subq_0.user__created_at__extract_doy + , subq_0.user__ds_partitioned__day + , subq_0.user__ds_partitioned__week + , subq_0.user__ds_partitioned__month + , subq_0.user__ds_partitioned__quarter + , subq_0.user__ds_partitioned__year + , subq_0.user__ds_partitioned__extract_year + , subq_0.user__ds_partitioned__extract_quarter + , subq_0.user__ds_partitioned__extract_month + , subq_0.user__ds_partitioned__extract_day + , subq_0.user__ds_partitioned__extract_dow + , subq_0.user__ds_partitioned__extract_doy + , subq_0.user__last_profile_edit_ts__millisecond + , subq_0.user__last_profile_edit_ts__second + , subq_0.user__last_profile_edit_ts__minute + , subq_0.user__last_profile_edit_ts__hour + , subq_0.user__last_profile_edit_ts__day + , subq_0.user__last_profile_edit_ts__week + , subq_0.user__last_profile_edit_ts__month + , subq_0.user__last_profile_edit_ts__quarter + , subq_0.user__last_profile_edit_ts__year + , subq_0.user__last_profile_edit_ts__extract_year + , subq_0.user__last_profile_edit_ts__extract_quarter + , subq_0.user__last_profile_edit_ts__extract_month + , subq_0.user__last_profile_edit_ts__extract_day + , subq_0.user__last_profile_edit_ts__extract_dow + , subq_0.user__last_profile_edit_ts__extract_doy + , subq_0.user__bio_added_ts__second + , subq_0.user__bio_added_ts__minute + , subq_0.user__bio_added_ts__hour + , subq_0.user__bio_added_ts__day + , subq_0.user__bio_added_ts__week + , subq_0.user__bio_added_ts__month + , subq_0.user__bio_added_ts__quarter + , subq_0.user__bio_added_ts__year + , subq_0.user__bio_added_ts__extract_year + , subq_0.user__bio_added_ts__extract_quarter + , subq_0.user__bio_added_ts__extract_month + , subq_0.user__bio_added_ts__extract_day + , subq_0.user__bio_added_ts__extract_dow + , subq_0.user__bio_added_ts__extract_doy + , subq_0.user__last_login_ts__minute + , subq_0.user__last_login_ts__hour + , subq_0.user__last_login_ts__day + , subq_0.user__last_login_ts__week + , subq_0.user__last_login_ts__month + , subq_0.user__last_login_ts__quarter + , subq_0.user__last_login_ts__year + , subq_0.user__last_login_ts__extract_year + , subq_0.user__last_login_ts__extract_quarter + , subq_0.user__last_login_ts__extract_month + , subq_0.user__last_login_ts__extract_day + , subq_0.user__last_login_ts__extract_dow + , subq_0.user__last_login_ts__extract_doy + , subq_0.user__archived_at__hour + , subq_0.user__archived_at__day + , subq_0.user__archived_at__week + , subq_0.user__archived_at__month + , subq_0.user__archived_at__quarter + , subq_0.user__archived_at__year + , subq_0.user__archived_at__extract_year + , subq_0.user__archived_at__extract_quarter + , subq_0.user__archived_at__extract_month + , subq_0.user__archived_at__extract_day + , subq_0.user__archived_at__extract_dow + , subq_0.user__archived_at__extract_doy + , subq_0.archived_at__hour AS metric_time__hour + , subq_0.archived_at__day AS metric_time__day + , subq_0.archived_at__week AS metric_time__week + , subq_0.archived_at__month AS metric_time__month + , subq_0.archived_at__quarter AS metric_time__quarter + , subq_0.archived_at__year AS metric_time__year + , subq_0.archived_at__extract_year AS metric_time__extract_year + , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter + , subq_0.archived_at__extract_month AS metric_time__extract_month + , subq_0.archived_at__extract_day AS metric_time__extract_day + , subq_0.archived_at__extract_dow AS metric_time__extract_dow + , subq_0.archived_at__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.home_state + , subq_0.user__home_state + , subq_0.archived_users FROM ( - -- Metric Time Dimension 'archived_at' + -- Read Elements From Semantic Model 'users_ds_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__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.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.last_profile_edit_ts__millisecond - , subq_0.last_profile_edit_ts__second - , subq_0.last_profile_edit_ts__minute - , subq_0.last_profile_edit_ts__hour - , subq_0.last_profile_edit_ts__day - , subq_0.last_profile_edit_ts__week - , subq_0.last_profile_edit_ts__month - , subq_0.last_profile_edit_ts__quarter - , subq_0.last_profile_edit_ts__year - , subq_0.last_profile_edit_ts__extract_year - , subq_0.last_profile_edit_ts__extract_quarter - , subq_0.last_profile_edit_ts__extract_month - , subq_0.last_profile_edit_ts__extract_day - , subq_0.last_profile_edit_ts__extract_dow - , subq_0.last_profile_edit_ts__extract_doy - , subq_0.bio_added_ts__second - , subq_0.bio_added_ts__minute - , subq_0.bio_added_ts__hour - , subq_0.bio_added_ts__day - , subq_0.bio_added_ts__week - , subq_0.bio_added_ts__month - , subq_0.bio_added_ts__quarter - , subq_0.bio_added_ts__year - , subq_0.bio_added_ts__extract_year - , subq_0.bio_added_ts__extract_quarter - , subq_0.bio_added_ts__extract_month - , subq_0.bio_added_ts__extract_day - , subq_0.bio_added_ts__extract_dow - , subq_0.bio_added_ts__extract_doy - , subq_0.last_login_ts__minute - , subq_0.last_login_ts__hour - , subq_0.last_login_ts__day - , subq_0.last_login_ts__week - , subq_0.last_login_ts__month - , subq_0.last_login_ts__quarter - , subq_0.last_login_ts__year - , subq_0.last_login_ts__extract_year - , subq_0.last_login_ts__extract_quarter - , subq_0.last_login_ts__extract_month - , subq_0.last_login_ts__extract_day - , subq_0.last_login_ts__extract_dow - , subq_0.last_login_ts__extract_doy - , subq_0.archived_at__hour - , subq_0.archived_at__day - , subq_0.archived_at__week - , subq_0.archived_at__month - , subq_0.archived_at__quarter - , subq_0.archived_at__year - , subq_0.archived_at__extract_year - , subq_0.archived_at__extract_quarter - , subq_0.archived_at__extract_month - , subq_0.archived_at__extract_day - , subq_0.archived_at__extract_dow - , subq_0.archived_at__extract_doy - , subq_0.user__ds__day - , subq_0.user__ds__week - , subq_0.user__ds__month - , subq_0.user__ds__quarter - , subq_0.user__ds__year - , subq_0.user__ds__extract_year - , subq_0.user__ds__extract_quarter - , subq_0.user__ds__extract_month - , subq_0.user__ds__extract_day - , subq_0.user__ds__extract_dow - , subq_0.user__ds__extract_doy - , subq_0.user__created_at__day - , subq_0.user__created_at__week - , subq_0.user__created_at__month - , subq_0.user__created_at__quarter - , subq_0.user__created_at__year - , subq_0.user__created_at__extract_year - , subq_0.user__created_at__extract_quarter - , subq_0.user__created_at__extract_month - , subq_0.user__created_at__extract_day - , subq_0.user__created_at__extract_dow - , subq_0.user__created_at__extract_doy - , subq_0.user__ds_partitioned__day - , subq_0.user__ds_partitioned__week - , subq_0.user__ds_partitioned__month - , subq_0.user__ds_partitioned__quarter - , subq_0.user__ds_partitioned__year - , subq_0.user__ds_partitioned__extract_year - , subq_0.user__ds_partitioned__extract_quarter - , subq_0.user__ds_partitioned__extract_month - , subq_0.user__ds_partitioned__extract_day - , subq_0.user__ds_partitioned__extract_dow - , subq_0.user__ds_partitioned__extract_doy - , subq_0.user__last_profile_edit_ts__millisecond - , subq_0.user__last_profile_edit_ts__second - , subq_0.user__last_profile_edit_ts__minute - , subq_0.user__last_profile_edit_ts__hour - , subq_0.user__last_profile_edit_ts__day - , subq_0.user__last_profile_edit_ts__week - , subq_0.user__last_profile_edit_ts__month - , subq_0.user__last_profile_edit_ts__quarter - , subq_0.user__last_profile_edit_ts__year - , subq_0.user__last_profile_edit_ts__extract_year - , subq_0.user__last_profile_edit_ts__extract_quarter - , subq_0.user__last_profile_edit_ts__extract_month - , subq_0.user__last_profile_edit_ts__extract_day - , subq_0.user__last_profile_edit_ts__extract_dow - , subq_0.user__last_profile_edit_ts__extract_doy - , subq_0.user__bio_added_ts__second - , subq_0.user__bio_added_ts__minute - , subq_0.user__bio_added_ts__hour - , subq_0.user__bio_added_ts__day - , subq_0.user__bio_added_ts__week - , subq_0.user__bio_added_ts__month - , subq_0.user__bio_added_ts__quarter - , subq_0.user__bio_added_ts__year - , subq_0.user__bio_added_ts__extract_year - , subq_0.user__bio_added_ts__extract_quarter - , subq_0.user__bio_added_ts__extract_month - , subq_0.user__bio_added_ts__extract_day - , subq_0.user__bio_added_ts__extract_dow - , subq_0.user__bio_added_ts__extract_doy - , subq_0.user__last_login_ts__minute - , subq_0.user__last_login_ts__hour - , subq_0.user__last_login_ts__day - , subq_0.user__last_login_ts__week - , subq_0.user__last_login_ts__month - , subq_0.user__last_login_ts__quarter - , subq_0.user__last_login_ts__year - , subq_0.user__last_login_ts__extract_year - , subq_0.user__last_login_ts__extract_quarter - , subq_0.user__last_login_ts__extract_month - , subq_0.user__last_login_ts__extract_day - , subq_0.user__last_login_ts__extract_dow - , subq_0.user__last_login_ts__extract_doy - , subq_0.user__archived_at__hour - , subq_0.user__archived_at__day - , subq_0.user__archived_at__week - , subq_0.user__archived_at__month - , subq_0.user__archived_at__quarter - , subq_0.user__archived_at__year - , subq_0.user__archived_at__extract_year - , subq_0.user__archived_at__extract_quarter - , subq_0.user__archived_at__extract_month - , subq_0.user__archived_at__extract_day - , subq_0.user__archived_at__extract_dow - , subq_0.user__archived_at__extract_doy - , subq_0.archived_at__hour AS metric_time__hour - , subq_0.archived_at__day AS metric_time__day - , subq_0.archived_at__week AS metric_time__week - , subq_0.archived_at__month AS metric_time__month - , subq_0.archived_at__quarter AS metric_time__quarter - , subq_0.archived_at__year AS metric_time__year - , subq_0.archived_at__extract_year AS metric_time__extract_year - , subq_0.archived_at__extract_quarter AS metric_time__extract_quarter - , subq_0.archived_at__extract_month AS metric_time__extract_month - , subq_0.archived_at__extract_day AS metric_time__extract_day - , subq_0.archived_at__extract_dow AS metric_time__extract_dow - , subq_0.archived_at__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.home_state - , subq_0.user__home_state - , subq_0.archived_users - FROM ( - -- Read Elements From Semantic Model 'users_ds_source' - SELECT - 1 AS new_users - , 1 AS archived_users - , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy - , 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 - , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond - , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy - , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second - , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy - , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute - , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour - , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day - , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week - , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year - , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy - , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour - , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day - , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week - , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month - , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter - , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year - , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year - , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter - , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month - , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow - , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy - , users_ds_source_src_28000.user_id AS user - FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS new_users + , 1 AS archived_users + , 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('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS archived_at__extract_doy + , 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 + , DATE_TRUNC('millisecond', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__millisecond + , DATE_TRUNC('second', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_profile_edit_ts) AS user__last_profile_edit_ts__extract_doy + , DATE_TRUNC('second', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__second + , DATE_TRUNC('minute', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__extract_doy + , DATE_TRUNC('minute', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__minute + , DATE_TRUNC('hour', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__hour + , DATE_TRUNC('day', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__day + , DATE_TRUNC('week', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__week + , DATE_TRUNC('month', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__year + , EXTRACT(year FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.last_login_ts) AS user__last_login_ts__extract_doy + , DATE_TRUNC('hour', users_ds_source_src_28000.archived_at) AS user__archived_at__hour + , DATE_TRUNC('day', users_ds_source_src_28000.archived_at) AS user__archived_at__day + , DATE_TRUNC('week', users_ds_source_src_28000.archived_at) AS user__archived_at__week + , DATE_TRUNC('month', users_ds_source_src_28000.archived_at) AS user__archived_at__month + , DATE_TRUNC('quarter', users_ds_source_src_28000.archived_at) AS user__archived_at__quarter + , DATE_TRUNC('year', users_ds_source_src_28000.archived_at) AS user__archived_at__year + , EXTRACT(year FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_year + , EXTRACT(quarter FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_quarter + , EXTRACT(month FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_month + , EXTRACT(day FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_dow + , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy + , users_ds_source_src_28000.user_id AS user + FROM ***************************.dim_users users_ds_source_src_28000 + ) subq_0 + ) subq_1 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 8e318e894d..57d1af7281 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -1,8 +1,8 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.archived_users AS archived_users_join_to_time_spine + subq_14.metric_time__day AS metric_time__day + , subq_13.archived_users AS archived_users_join_to_time_spine FROM ( -- Filter Time Spine SELECT @@ -12,8 +12,8 @@ FROM ( SELECT ts AS metric_time__hour , DATE_TRUNC('day', ts) AS metric_time__day - FROM ***************************.mf_time_spine_hour subq_17 - ) subq_18 + FROM ***************************.mf_time_spine_hour subq_15 + ) subq_16 WHERE ( metric_time__hour > '2020-01-01 00:09:00' ) AND ( @@ -21,7 +21,7 @@ FROM ( ) GROUP BY metric_time__day -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['archived_users', 'metric_time__day'] @@ -32,16 +32,15 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' - -- Pass Only Elements: ['archived_users', 'metric_time__day', 'metric_time__hour'] SELECT DATE_TRUNC('hour', archived_at) AS metric_time__hour , DATE_TRUNC('day', archived_at) AS metric_time__day , 1 AS archived_users FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_12 + ) subq_10 WHERE (metric_time__hour > '2020-01-01 00:09:00') AND (metric_time__day = '2020-01-01') GROUP BY metric_time__day -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql index cdd9fb67d7..57e296fa0b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql @@ -1,360 +1,448 @@ -- Compute Metrics via Expressions SELECT - subq_11.metric_time__day - , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 + subq_10.metric_time__day + , COALESCE(subq_10.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_10.metric_time__day - , subq_10.bookings + subq_9.metric_time__day + , subq_9.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.bookings AS bookings + subq_6.metric_time__day AS metric_time__day + , subq_5.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_9.metric_time__day + subq_8.metric_time__day FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day - , DATE_TRUNC('week', subq_8.ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_8 - WHERE subq_8.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_9 + subq_7.ds AS metric_time__day + , DATE_TRUNC('week', subq_7.ds) AS metric_time__week + FROM ***************************.mf_time_spine subq_7 + WHERE subq_7.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_8 WHERE metric_time__week > '2020-01-01' - ) subq_7 + ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , SUM(subq_5.bookings) AS bookings + subq_4.metric_time__day + , SUM(subq_4.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_4.metric_time__day - , subq_4.bookings + subq_3.metric_time__day + , subq_3.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_3.metric_time__day - , subq_3.metric_time__week - , subq_3.bookings + 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.metric_time__day + , subq_2.metric_time__week + , subq_2.metric_time__month + , subq_2.metric_time__quarter + , subq_2.metric_time__year + , 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_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] + -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_2.metric_time__day - , subq_2.metric_time__week - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] + -- 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_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_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_2 - ) subq_3 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + WHERE subq_1.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + ) subq_2 WHERE metric_time__week > '2020-01-01' - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 GROUP BY - subq_5.metric_time__day - ) subq_6 + subq_4.metric_time__day + ) subq_5 ON - subq_7.metric_time__day = subq_6.metric_time__day - ) subq_10 - WHERE subq_10.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_11 + subq_6.metric_time__day = subq_5.metric_time__day + ) subq_9 + WHERE subq_9.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' +) subq_10 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql index 19119be28f..09037ea1d9 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Join to Time Spine Dataset -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_18.bookings AS bookings + subq_17.metric_time__day AS metric_time__day + , subq_16.bookings AS bookings FROM ( -- Filter Time Spine SELECT @@ -17,11 +17,11 @@ FROM ( SELECT ds AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week - FROM ***************************.mf_time_spine subq_20 + FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_21 + ) subq_19 WHERE metric_time__week > '2020-01-01' - ) subq_19 + ) subq_17 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -33,19 +33,18 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-03T00:00:00, 2020-01-05T00:00:00] - -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__week'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 WHERE DATE_TRUNC('day', ds) BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' - ) subq_15 + ) subq_13 WHERE metric_time__week > '2020-01-01' GROUP BY metric_time__day - ) subq_18 + ) subq_16 ON - subq_19.metric_time__day = subq_18.metric_time__day - WHERE subq_19.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' -) subq_23 + subq_17.metric_time__day = subq_16.metric_time__day + WHERE subq_17.metric_time__day BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' +) subq_21 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 6163da77c9..c562a10d29 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY listing__user__bio_added_ts__minute -) subq_12 +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index fdcb7133a2..258dac38ec 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATETIME_TRUNC(ds_partitioned, day) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY listing__user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 4e6c3b98c4..6372447730 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.listing__user__bio_added_ts__minute -) subq_12 + subq_10.listing__user__bio_added_ts__minute +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index d93a3918ba..43eaac5acd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY - subq_22.user__bio_added_ts__minute + subq_20.user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 1f119872ca..a09d45dae9 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.listing__user__bio_added_ts__minute -) subq_12 + subq_10.listing__user__bio_added_ts__minute +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index d93a3918ba..43eaac5acd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY - subq_22.user__bio_added_ts__minute + subq_20.user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 565b27172d..44899f5519 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.listing__user__bio_added_ts__minute -) subq_12 + subq_10.listing__user__bio_added_ts__minute +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index d93a3918ba..43eaac5acd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY - subq_22.user__bio_added_ts__minute + subq_20.user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 045f91b040..2f96e1b355 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.listing__user__bio_added_ts__minute -) subq_12 + subq_10.listing__user__bio_added_ts__minute +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index d93a3918ba..43eaac5acd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY - subq_22.user__bio_added_ts__minute + subq_20.user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql index 1e33b6dfe2..3ba5278295 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0.sql @@ -1,472 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_12.listing__user__bio_added_ts__minute - , subq_12.bookings + subq_11.listing__user__bio_added_ts__minute + , subq_11.bookings FROM ( -- Aggregate Measures SELECT - subq_11.listing__user__bio_added_ts__minute - , SUM(subq_11.bookings) AS bookings + subq_10.listing__user__bio_added_ts__minute + , SUM(subq_10.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__user__bio_added_ts__minute'] SELECT - subq_10.listing__user__bio_added_ts__minute - , subq_10.bookings + subq_9.listing__user__bio_added_ts__minute + , subq_9.bookings FROM ( -- Join Standard Outputs SELECT - subq_9.user__ds_partitioned__day AS listing__user__ds_partitioned__day - , subq_9.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_8.user__ds_partitioned__day AS listing__user__ds_partitioned__day + , subq_8.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , 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__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 FROM ( - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] SELECT - subq_8.user__ds_partitioned__day - , subq_8.user__bio_added_ts__minute - , subq_8.listing + subq_7.user__ds_partitioned__day + , subq_7.user__bio_added_ts__minute + , subq_7.listing FROM ( -- Join Standard Outputs SELECT - subq_7.home_state AS user__home_state - , subq_7.ds__day AS user__ds__day - , subq_7.ds__week AS user__ds__week - , subq_7.ds__month AS user__ds__month - , subq_7.ds__quarter AS user__ds__quarter - , subq_7.ds__year AS user__ds__year - , subq_7.ds__extract_year AS user__ds__extract_year - , subq_7.ds__extract_quarter AS user__ds__extract_quarter - , subq_7.ds__extract_month AS user__ds__extract_month - , subq_7.ds__extract_day AS user__ds__extract_day - , subq_7.ds__extract_dow AS user__ds__extract_dow - , subq_7.ds__extract_doy AS user__ds__extract_doy - , subq_7.created_at__day AS user__created_at__day - , subq_7.created_at__week AS user__created_at__week - , subq_7.created_at__month AS user__created_at__month - , subq_7.created_at__quarter AS user__created_at__quarter - , subq_7.created_at__year AS user__created_at__year - , subq_7.created_at__extract_year AS user__created_at__extract_year - , subq_7.created_at__extract_quarter AS user__created_at__extract_quarter - , subq_7.created_at__extract_month AS user__created_at__extract_month - , subq_7.created_at__extract_day AS user__created_at__extract_day - , subq_7.created_at__extract_dow AS user__created_at__extract_dow - , subq_7.created_at__extract_doy AS user__created_at__extract_doy - , subq_7.ds_partitioned__day AS user__ds_partitioned__day - , subq_7.ds_partitioned__week AS user__ds_partitioned__week - , subq_7.ds_partitioned__month AS user__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS user__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS user__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS user__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS user__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS user__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy - , subq_7.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond - , subq_7.last_profile_edit_ts__second AS user__last_profile_edit_ts__second - , subq_7.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute - , subq_7.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour - , subq_7.last_profile_edit_ts__day AS user__last_profile_edit_ts__day - , subq_7.last_profile_edit_ts__week AS user__last_profile_edit_ts__week - , subq_7.last_profile_edit_ts__month AS user__last_profile_edit_ts__month - , subq_7.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter - , subq_7.last_profile_edit_ts__year AS user__last_profile_edit_ts__year - , subq_7.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year - , subq_7.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter - , subq_7.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month - , subq_7.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day - , subq_7.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow - , subq_7.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy - , subq_7.bio_added_ts__second AS user__bio_added_ts__second - , subq_7.bio_added_ts__minute AS user__bio_added_ts__minute - , subq_7.bio_added_ts__hour AS user__bio_added_ts__hour - , subq_7.bio_added_ts__day AS user__bio_added_ts__day - , subq_7.bio_added_ts__week AS user__bio_added_ts__week - , subq_7.bio_added_ts__month AS user__bio_added_ts__month - , subq_7.bio_added_ts__quarter AS user__bio_added_ts__quarter - , subq_7.bio_added_ts__year AS user__bio_added_ts__year - , subq_7.bio_added_ts__extract_year AS user__bio_added_ts__extract_year - , subq_7.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter - , subq_7.bio_added_ts__extract_month AS user__bio_added_ts__extract_month - , subq_7.bio_added_ts__extract_day AS user__bio_added_ts__extract_day - , subq_7.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow - , subq_7.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy - , subq_7.last_login_ts__minute AS user__last_login_ts__minute - , subq_7.last_login_ts__hour AS user__last_login_ts__hour - , subq_7.last_login_ts__day AS user__last_login_ts__day - , subq_7.last_login_ts__week AS user__last_login_ts__week - , subq_7.last_login_ts__month AS user__last_login_ts__month - , subq_7.last_login_ts__quarter AS user__last_login_ts__quarter - , subq_7.last_login_ts__year AS user__last_login_ts__year - , subq_7.last_login_ts__extract_year AS user__last_login_ts__extract_year - , subq_7.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter - , subq_7.last_login_ts__extract_month AS user__last_login_ts__extract_month - , subq_7.last_login_ts__extract_day AS user__last_login_ts__extract_day - , subq_7.last_login_ts__extract_dow AS user__last_login_ts__extract_dow - , subq_7.last_login_ts__extract_doy AS user__last_login_ts__extract_doy - , subq_7.archived_at__hour AS user__archived_at__hour - , subq_7.archived_at__day AS user__archived_at__day - , subq_7.archived_at__week AS user__archived_at__week - , subq_7.archived_at__month AS user__archived_at__month - , subq_7.archived_at__quarter AS user__archived_at__quarter - , subq_7.archived_at__year AS user__archived_at__year - , subq_7.archived_at__extract_year AS user__archived_at__extract_year - , subq_7.archived_at__extract_quarter AS user__archived_at__extract_quarter - , subq_7.archived_at__extract_month AS user__archived_at__extract_month - , subq_7.archived_at__extract_day AS user__archived_at__extract_day - , subq_7.archived_at__extract_dow AS user__archived_at__extract_dow - , subq_7.archived_at__extract_doy AS user__archived_at__extract_doy - , subq_7.metric_time__day AS user__metric_time__day - , subq_7.metric_time__week AS user__metric_time__week - , subq_7.metric_time__month AS user__metric_time__month - , subq_7.metric_time__quarter AS user__metric_time__quarter - , subq_7.metric_time__year AS user__metric_time__year - , subq_7.metric_time__extract_year AS user__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS user__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS user__metric_time__extract_month - , subq_7.metric_time__extract_day AS user__metric_time__extract_day - , subq_7.metric_time__extract_dow AS user__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS user__metric_time__extract_doy - , 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.created_at__day AS created_at__day - , subq_4.created_at__week AS created_at__week - , subq_4.created_at__month AS created_at__month - , subq_4.created_at__quarter AS created_at__quarter - , subq_4.created_at__year AS created_at__year - , subq_4.created_at__extract_year AS created_at__extract_year - , subq_4.created_at__extract_quarter AS created_at__extract_quarter - , subq_4.created_at__extract_month AS created_at__extract_month - , subq_4.created_at__extract_day AS created_at__extract_day - , subq_4.created_at__extract_dow AS created_at__extract_dow - , subq_4.created_at__extract_doy AS created_at__extract_doy - , subq_4.listing__ds__day AS listing__ds__day - , subq_4.listing__ds__week AS listing__ds__week - , subq_4.listing__ds__month AS listing__ds__month - , subq_4.listing__ds__quarter AS listing__ds__quarter - , subq_4.listing__ds__year AS listing__ds__year - , subq_4.listing__ds__extract_year AS listing__ds__extract_year - , subq_4.listing__ds__extract_quarter AS listing__ds__extract_quarter - , subq_4.listing__ds__extract_month AS listing__ds__extract_month - , subq_4.listing__ds__extract_day AS listing__ds__extract_day - , subq_4.listing__ds__extract_dow AS listing__ds__extract_dow - , subq_4.listing__ds__extract_doy AS listing__ds__extract_doy - , subq_4.listing__created_at__day AS listing__created_at__day - , subq_4.listing__created_at__week AS listing__created_at__week - , subq_4.listing__created_at__month AS listing__created_at__month - , subq_4.listing__created_at__quarter AS listing__created_at__quarter - , subq_4.listing__created_at__year AS listing__created_at__year - , subq_4.listing__created_at__extract_year AS listing__created_at__extract_year - , subq_4.listing__created_at__extract_quarter AS listing__created_at__extract_quarter - , subq_4.listing__created_at__extract_month AS listing__created_at__extract_month - , subq_4.listing__created_at__extract_day AS listing__created_at__extract_day - , subq_4.listing__created_at__extract_dow AS listing__created_at__extract_dow - , subq_4.listing__created_at__extract_doy AS listing__created_at__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.listing AS listing - , subq_4.user AS user - , subq_4.listing__user AS listing__user - , subq_4.country_latest AS country_latest - , subq_4.is_lux_latest AS is_lux_latest - , subq_4.capacity_latest AS capacity_latest - , subq_4.listing__country_latest AS listing__country_latest - , subq_4.listing__is_lux_latest AS listing__is_lux_latest - , subq_4.listing__capacity_latest AS listing__capacity_latest - , subq_4.listings AS listings - , subq_4.largest_listing AS largest_listing - , subq_4.smallest_listing AS smallest_listing + subq_6.home_state AS user__home_state + , subq_6.ds__day AS user__ds__day + , subq_6.ds__week AS user__ds__week + , subq_6.ds__month AS user__ds__month + , subq_6.ds__quarter AS user__ds__quarter + , subq_6.ds__year AS user__ds__year + , subq_6.ds__extract_year AS user__ds__extract_year + , subq_6.ds__extract_quarter AS user__ds__extract_quarter + , subq_6.ds__extract_month AS user__ds__extract_month + , subq_6.ds__extract_day AS user__ds__extract_day + , subq_6.ds__extract_dow AS user__ds__extract_dow + , subq_6.ds__extract_doy AS user__ds__extract_doy + , subq_6.created_at__day AS user__created_at__day + , subq_6.created_at__week AS user__created_at__week + , subq_6.created_at__month AS user__created_at__month + , subq_6.created_at__quarter AS user__created_at__quarter + , subq_6.created_at__year AS user__created_at__year + , subq_6.created_at__extract_year AS user__created_at__extract_year + , subq_6.created_at__extract_quarter AS user__created_at__extract_quarter + , subq_6.created_at__extract_month AS user__created_at__extract_month + , subq_6.created_at__extract_day AS user__created_at__extract_day + , subq_6.created_at__extract_dow AS user__created_at__extract_dow + , subq_6.created_at__extract_doy AS user__created_at__extract_doy + , subq_6.ds_partitioned__day AS user__ds_partitioned__day + , subq_6.ds_partitioned__week AS user__ds_partitioned__week + , subq_6.ds_partitioned__month AS user__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS user__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS user__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS user__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS user__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS user__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS user__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS user__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS user__ds_partitioned__extract_doy + , subq_6.last_profile_edit_ts__millisecond AS user__last_profile_edit_ts__millisecond + , subq_6.last_profile_edit_ts__second AS user__last_profile_edit_ts__second + , subq_6.last_profile_edit_ts__minute AS user__last_profile_edit_ts__minute + , subq_6.last_profile_edit_ts__hour AS user__last_profile_edit_ts__hour + , subq_6.last_profile_edit_ts__day AS user__last_profile_edit_ts__day + , subq_6.last_profile_edit_ts__week AS user__last_profile_edit_ts__week + , subq_6.last_profile_edit_ts__month AS user__last_profile_edit_ts__month + , subq_6.last_profile_edit_ts__quarter AS user__last_profile_edit_ts__quarter + , subq_6.last_profile_edit_ts__year AS user__last_profile_edit_ts__year + , subq_6.last_profile_edit_ts__extract_year AS user__last_profile_edit_ts__extract_year + , subq_6.last_profile_edit_ts__extract_quarter AS user__last_profile_edit_ts__extract_quarter + , subq_6.last_profile_edit_ts__extract_month AS user__last_profile_edit_ts__extract_month + , subq_6.last_profile_edit_ts__extract_day AS user__last_profile_edit_ts__extract_day + , subq_6.last_profile_edit_ts__extract_dow AS user__last_profile_edit_ts__extract_dow + , subq_6.last_profile_edit_ts__extract_doy AS user__last_profile_edit_ts__extract_doy + , subq_6.bio_added_ts__second AS user__bio_added_ts__second + , subq_6.bio_added_ts__minute AS user__bio_added_ts__minute + , subq_6.bio_added_ts__hour AS user__bio_added_ts__hour + , subq_6.bio_added_ts__day AS user__bio_added_ts__day + , subq_6.bio_added_ts__week AS user__bio_added_ts__week + , subq_6.bio_added_ts__month AS user__bio_added_ts__month + , subq_6.bio_added_ts__quarter AS user__bio_added_ts__quarter + , subq_6.bio_added_ts__year AS user__bio_added_ts__year + , subq_6.bio_added_ts__extract_year AS user__bio_added_ts__extract_year + , subq_6.bio_added_ts__extract_quarter AS user__bio_added_ts__extract_quarter + , subq_6.bio_added_ts__extract_month AS user__bio_added_ts__extract_month + , subq_6.bio_added_ts__extract_day AS user__bio_added_ts__extract_day + , subq_6.bio_added_ts__extract_dow AS user__bio_added_ts__extract_dow + , subq_6.bio_added_ts__extract_doy AS user__bio_added_ts__extract_doy + , subq_6.last_login_ts__minute AS user__last_login_ts__minute + , subq_6.last_login_ts__hour AS user__last_login_ts__hour + , subq_6.last_login_ts__day AS user__last_login_ts__day + , subq_6.last_login_ts__week AS user__last_login_ts__week + , subq_6.last_login_ts__month AS user__last_login_ts__month + , subq_6.last_login_ts__quarter AS user__last_login_ts__quarter + , subq_6.last_login_ts__year AS user__last_login_ts__year + , subq_6.last_login_ts__extract_year AS user__last_login_ts__extract_year + , subq_6.last_login_ts__extract_quarter AS user__last_login_ts__extract_quarter + , subq_6.last_login_ts__extract_month AS user__last_login_ts__extract_month + , subq_6.last_login_ts__extract_day AS user__last_login_ts__extract_day + , subq_6.last_login_ts__extract_dow AS user__last_login_ts__extract_dow + , subq_6.last_login_ts__extract_doy AS user__last_login_ts__extract_doy + , subq_6.archived_at__hour AS user__archived_at__hour + , subq_6.archived_at__day AS user__archived_at__day + , subq_6.archived_at__week AS user__archived_at__week + , subq_6.archived_at__month AS user__archived_at__month + , subq_6.archived_at__quarter AS user__archived_at__quarter + , subq_6.archived_at__year AS user__archived_at__year + , subq_6.archived_at__extract_year AS user__archived_at__extract_year + , subq_6.archived_at__extract_quarter AS user__archived_at__extract_quarter + , subq_6.archived_at__extract_month AS user__archived_at__extract_month + , subq_6.archived_at__extract_day AS user__archived_at__extract_day + , subq_6.archived_at__extract_dow AS user__archived_at__extract_dow + , subq_6.archived_at__extract_doy AS user__archived_at__extract_doy + , subq_6.metric_time__day AS user__metric_time__day + , subq_6.metric_time__week AS user__metric_time__week + , subq_6.metric_time__month AS user__metric_time__month + , subq_6.metric_time__quarter AS user__metric_time__quarter + , subq_6.metric_time__year AS user__metric_time__year + , subq_6.metric_time__extract_year AS user__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS user__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS user__metric_time__extract_month + , subq_6.metric_time__extract_day AS user__metric_time__extract_day + , subq_6.metric_time__extract_dow AS user__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS user__metric_time__extract_doy + , subq_3.ds__day AS ds__day + , subq_3.ds__week AS ds__week + , subq_3.ds__month AS ds__month + , subq_3.ds__quarter AS ds__quarter + , subq_3.ds__year AS ds__year + , subq_3.ds__extract_year AS ds__extract_year + , subq_3.ds__extract_quarter AS ds__extract_quarter + , subq_3.ds__extract_month AS ds__extract_month + , subq_3.ds__extract_day AS ds__extract_day + , subq_3.ds__extract_dow AS ds__extract_dow + , subq_3.ds__extract_doy AS ds__extract_doy + , subq_3.created_at__day AS created_at__day + , subq_3.created_at__week AS created_at__week + , subq_3.created_at__month AS created_at__month + , subq_3.created_at__quarter AS created_at__quarter + , subq_3.created_at__year AS created_at__year + , subq_3.created_at__extract_year AS created_at__extract_year + , subq_3.created_at__extract_quarter AS created_at__extract_quarter + , subq_3.created_at__extract_month AS created_at__extract_month + , subq_3.created_at__extract_day AS created_at__extract_day + , subq_3.created_at__extract_dow AS created_at__extract_dow + , subq_3.created_at__extract_doy AS created_at__extract_doy + , subq_3.listing__ds__day AS listing__ds__day + , subq_3.listing__ds__week AS listing__ds__week + , subq_3.listing__ds__month AS listing__ds__month + , subq_3.listing__ds__quarter AS listing__ds__quarter + , subq_3.listing__ds__year AS listing__ds__year + , subq_3.listing__ds__extract_year AS listing__ds__extract_year + , subq_3.listing__ds__extract_quarter AS listing__ds__extract_quarter + , subq_3.listing__ds__extract_month AS listing__ds__extract_month + , subq_3.listing__ds__extract_day AS listing__ds__extract_day + , subq_3.listing__ds__extract_dow AS listing__ds__extract_dow + , subq_3.listing__ds__extract_doy AS listing__ds__extract_doy + , subq_3.listing__created_at__day AS listing__created_at__day + , subq_3.listing__created_at__week AS listing__created_at__week + , subq_3.listing__created_at__month AS listing__created_at__month + , subq_3.listing__created_at__quarter AS listing__created_at__quarter + , subq_3.listing__created_at__year AS listing__created_at__year + , subq_3.listing__created_at__extract_year AS listing__created_at__extract_year + , subq_3.listing__created_at__extract_quarter AS listing__created_at__extract_quarter + , subq_3.listing__created_at__extract_month AS listing__created_at__extract_month + , subq_3.listing__created_at__extract_day AS listing__created_at__extract_day + , subq_3.listing__created_at__extract_dow AS listing__created_at__extract_dow + , subq_3.listing__created_at__extract_doy AS listing__created_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.user AS user + , subq_3.listing__user AS listing__user + , subq_3.country_latest AS country_latest + , subq_3.is_lux_latest AS is_lux_latest + , subq_3.capacity_latest AS capacity_latest + , subq_3.listing__country_latest AS listing__country_latest + , subq_3.listing__is_lux_latest AS listing__is_lux_latest + , subq_3.listing__capacity_latest AS listing__capacity_latest + , subq_3.listings AS listings + , subq_3.largest_listing AS largest_listing + , subq_3.smallest_listing AS smallest_listing 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_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( -- Read Elements From Semantic Model 'listings_latest' SELECT @@ -527,8 +615,8 @@ FROM ( , listings_latest_src_28000.user_id AS user , listings_latest_src_28000.user_id AS listing__user FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state', @@ -721,386 +809,386 @@ FROM ( -- 'user', -- ] 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.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.last_profile_edit_ts__millisecond - , subq_6.last_profile_edit_ts__second - , subq_6.last_profile_edit_ts__minute - , subq_6.last_profile_edit_ts__hour - , subq_6.last_profile_edit_ts__day - , subq_6.last_profile_edit_ts__week - , subq_6.last_profile_edit_ts__month - , subq_6.last_profile_edit_ts__quarter - , subq_6.last_profile_edit_ts__year - , subq_6.last_profile_edit_ts__extract_year - , subq_6.last_profile_edit_ts__extract_quarter - , subq_6.last_profile_edit_ts__extract_month - , subq_6.last_profile_edit_ts__extract_day - , subq_6.last_profile_edit_ts__extract_dow - , subq_6.last_profile_edit_ts__extract_doy - , subq_6.bio_added_ts__second - , subq_6.bio_added_ts__minute - , subq_6.bio_added_ts__hour - , subq_6.bio_added_ts__day - , subq_6.bio_added_ts__week - , subq_6.bio_added_ts__month - , subq_6.bio_added_ts__quarter - , subq_6.bio_added_ts__year - , subq_6.bio_added_ts__extract_year - , subq_6.bio_added_ts__extract_quarter - , subq_6.bio_added_ts__extract_month - , subq_6.bio_added_ts__extract_day - , subq_6.bio_added_ts__extract_dow - , subq_6.bio_added_ts__extract_doy - , subq_6.last_login_ts__minute - , subq_6.last_login_ts__hour - , subq_6.last_login_ts__day - , subq_6.last_login_ts__week - , subq_6.last_login_ts__month - , subq_6.last_login_ts__quarter - , subq_6.last_login_ts__year - , subq_6.last_login_ts__extract_year - , subq_6.last_login_ts__extract_quarter - , subq_6.last_login_ts__extract_month - , subq_6.last_login_ts__extract_day - , subq_6.last_login_ts__extract_dow - , subq_6.last_login_ts__extract_doy - , subq_6.archived_at__hour - , subq_6.archived_at__day - , subq_6.archived_at__week - , subq_6.archived_at__month - , subq_6.archived_at__quarter - , subq_6.archived_at__year - , subq_6.archived_at__extract_year - , subq_6.archived_at__extract_quarter - , subq_6.archived_at__extract_month - , subq_6.archived_at__extract_day - , subq_6.archived_at__extract_dow - , subq_6.archived_at__extract_doy - , subq_6.user__ds__day - , subq_6.user__ds__week - , subq_6.user__ds__month - , subq_6.user__ds__quarter - , subq_6.user__ds__year - , subq_6.user__ds__extract_year - , subq_6.user__ds__extract_quarter - , subq_6.user__ds__extract_month - , subq_6.user__ds__extract_day - , subq_6.user__ds__extract_dow - , subq_6.user__ds__extract_doy - , subq_6.user__created_at__day - , subq_6.user__created_at__week - , subq_6.user__created_at__month - , subq_6.user__created_at__quarter - , subq_6.user__created_at__year - , subq_6.user__created_at__extract_year - , subq_6.user__created_at__extract_quarter - , subq_6.user__created_at__extract_month - , subq_6.user__created_at__extract_day - , subq_6.user__created_at__extract_dow - , subq_6.user__created_at__extract_doy - , subq_6.user__ds_partitioned__day - , subq_6.user__ds_partitioned__week - , subq_6.user__ds_partitioned__month - , subq_6.user__ds_partitioned__quarter - , subq_6.user__ds_partitioned__year - , subq_6.user__ds_partitioned__extract_year - , subq_6.user__ds_partitioned__extract_quarter - , subq_6.user__ds_partitioned__extract_month - , subq_6.user__ds_partitioned__extract_day - , subq_6.user__ds_partitioned__extract_dow - , subq_6.user__ds_partitioned__extract_doy - , subq_6.user__last_profile_edit_ts__millisecond - , subq_6.user__last_profile_edit_ts__second - , subq_6.user__last_profile_edit_ts__minute - , subq_6.user__last_profile_edit_ts__hour - , subq_6.user__last_profile_edit_ts__day - , subq_6.user__last_profile_edit_ts__week - , subq_6.user__last_profile_edit_ts__month - , subq_6.user__last_profile_edit_ts__quarter - , subq_6.user__last_profile_edit_ts__year - , subq_6.user__last_profile_edit_ts__extract_year - , subq_6.user__last_profile_edit_ts__extract_quarter - , subq_6.user__last_profile_edit_ts__extract_month - , subq_6.user__last_profile_edit_ts__extract_day - , subq_6.user__last_profile_edit_ts__extract_dow - , subq_6.user__last_profile_edit_ts__extract_doy - , subq_6.user__bio_added_ts__second - , subq_6.user__bio_added_ts__minute - , subq_6.user__bio_added_ts__hour - , subq_6.user__bio_added_ts__day - , subq_6.user__bio_added_ts__week - , subq_6.user__bio_added_ts__month - , subq_6.user__bio_added_ts__quarter - , subq_6.user__bio_added_ts__year - , subq_6.user__bio_added_ts__extract_year - , subq_6.user__bio_added_ts__extract_quarter - , subq_6.user__bio_added_ts__extract_month - , subq_6.user__bio_added_ts__extract_day - , subq_6.user__bio_added_ts__extract_dow - , subq_6.user__bio_added_ts__extract_doy - , subq_6.user__last_login_ts__minute - , subq_6.user__last_login_ts__hour - , subq_6.user__last_login_ts__day - , subq_6.user__last_login_ts__week - , subq_6.user__last_login_ts__month - , subq_6.user__last_login_ts__quarter - , subq_6.user__last_login_ts__year - , subq_6.user__last_login_ts__extract_year - , subq_6.user__last_login_ts__extract_quarter - , subq_6.user__last_login_ts__extract_month - , subq_6.user__last_login_ts__extract_day - , subq_6.user__last_login_ts__extract_dow - , subq_6.user__last_login_ts__extract_doy - , subq_6.user__archived_at__hour - , subq_6.user__archived_at__day - , subq_6.user__archived_at__week - , subq_6.user__archived_at__month - , subq_6.user__archived_at__quarter - , subq_6.user__archived_at__year - , subq_6.user__archived_at__extract_year - , subq_6.user__archived_at__extract_quarter - , subq_6.user__archived_at__extract_month - , subq_6.user__archived_at__extract_day - , subq_6.user__archived_at__extract_dow - , subq_6.user__archived_at__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.user - , subq_6.home_state - , subq_6.user__home_state + 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.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.last_profile_edit_ts__millisecond + , subq_5.last_profile_edit_ts__second + , subq_5.last_profile_edit_ts__minute + , subq_5.last_profile_edit_ts__hour + , subq_5.last_profile_edit_ts__day + , subq_5.last_profile_edit_ts__week + , subq_5.last_profile_edit_ts__month + , subq_5.last_profile_edit_ts__quarter + , subq_5.last_profile_edit_ts__year + , subq_5.last_profile_edit_ts__extract_year + , subq_5.last_profile_edit_ts__extract_quarter + , subq_5.last_profile_edit_ts__extract_month + , subq_5.last_profile_edit_ts__extract_day + , subq_5.last_profile_edit_ts__extract_dow + , subq_5.last_profile_edit_ts__extract_doy + , subq_5.bio_added_ts__second + , subq_5.bio_added_ts__minute + , subq_5.bio_added_ts__hour + , subq_5.bio_added_ts__day + , subq_5.bio_added_ts__week + , subq_5.bio_added_ts__month + , subq_5.bio_added_ts__quarter + , subq_5.bio_added_ts__year + , subq_5.bio_added_ts__extract_year + , subq_5.bio_added_ts__extract_quarter + , subq_5.bio_added_ts__extract_month + , subq_5.bio_added_ts__extract_day + , subq_5.bio_added_ts__extract_dow + , subq_5.bio_added_ts__extract_doy + , subq_5.last_login_ts__minute + , subq_5.last_login_ts__hour + , subq_5.last_login_ts__day + , subq_5.last_login_ts__week + , subq_5.last_login_ts__month + , subq_5.last_login_ts__quarter + , subq_5.last_login_ts__year + , subq_5.last_login_ts__extract_year + , subq_5.last_login_ts__extract_quarter + , subq_5.last_login_ts__extract_month + , subq_5.last_login_ts__extract_day + , subq_5.last_login_ts__extract_dow + , subq_5.last_login_ts__extract_doy + , subq_5.archived_at__hour + , subq_5.archived_at__day + , subq_5.archived_at__week + , subq_5.archived_at__month + , subq_5.archived_at__quarter + , subq_5.archived_at__year + , subq_5.archived_at__extract_year + , subq_5.archived_at__extract_quarter + , subq_5.archived_at__extract_month + , subq_5.archived_at__extract_day + , subq_5.archived_at__extract_dow + , subq_5.archived_at__extract_doy + , subq_5.user__ds__day + , subq_5.user__ds__week + , subq_5.user__ds__month + , subq_5.user__ds__quarter + , subq_5.user__ds__year + , subq_5.user__ds__extract_year + , subq_5.user__ds__extract_quarter + , subq_5.user__ds__extract_month + , subq_5.user__ds__extract_day + , subq_5.user__ds__extract_dow + , subq_5.user__ds__extract_doy + , subq_5.user__created_at__day + , subq_5.user__created_at__week + , subq_5.user__created_at__month + , subq_5.user__created_at__quarter + , subq_5.user__created_at__year + , subq_5.user__created_at__extract_year + , subq_5.user__created_at__extract_quarter + , subq_5.user__created_at__extract_month + , subq_5.user__created_at__extract_day + , subq_5.user__created_at__extract_dow + , subq_5.user__created_at__extract_doy + , subq_5.user__ds_partitioned__day + , subq_5.user__ds_partitioned__week + , subq_5.user__ds_partitioned__month + , subq_5.user__ds_partitioned__quarter + , subq_5.user__ds_partitioned__year + , subq_5.user__ds_partitioned__extract_year + , subq_5.user__ds_partitioned__extract_quarter + , subq_5.user__ds_partitioned__extract_month + , subq_5.user__ds_partitioned__extract_day + , subq_5.user__ds_partitioned__extract_dow + , subq_5.user__ds_partitioned__extract_doy + , subq_5.user__last_profile_edit_ts__millisecond + , subq_5.user__last_profile_edit_ts__second + , subq_5.user__last_profile_edit_ts__minute + , subq_5.user__last_profile_edit_ts__hour + , subq_5.user__last_profile_edit_ts__day + , subq_5.user__last_profile_edit_ts__week + , subq_5.user__last_profile_edit_ts__month + , subq_5.user__last_profile_edit_ts__quarter + , subq_5.user__last_profile_edit_ts__year + , subq_5.user__last_profile_edit_ts__extract_year + , subq_5.user__last_profile_edit_ts__extract_quarter + , subq_5.user__last_profile_edit_ts__extract_month + , subq_5.user__last_profile_edit_ts__extract_day + , subq_5.user__last_profile_edit_ts__extract_dow + , subq_5.user__last_profile_edit_ts__extract_doy + , subq_5.user__bio_added_ts__second + , subq_5.user__bio_added_ts__minute + , subq_5.user__bio_added_ts__hour + , subq_5.user__bio_added_ts__day + , subq_5.user__bio_added_ts__week + , subq_5.user__bio_added_ts__month + , subq_5.user__bio_added_ts__quarter + , subq_5.user__bio_added_ts__year + , subq_5.user__bio_added_ts__extract_year + , subq_5.user__bio_added_ts__extract_quarter + , subq_5.user__bio_added_ts__extract_month + , subq_5.user__bio_added_ts__extract_day + , subq_5.user__bio_added_ts__extract_dow + , subq_5.user__bio_added_ts__extract_doy + , subq_5.user__last_login_ts__minute + , subq_5.user__last_login_ts__hour + , subq_5.user__last_login_ts__day + , subq_5.user__last_login_ts__week + , subq_5.user__last_login_ts__month + , subq_5.user__last_login_ts__quarter + , subq_5.user__last_login_ts__year + , subq_5.user__last_login_ts__extract_year + , subq_5.user__last_login_ts__extract_quarter + , subq_5.user__last_login_ts__extract_month + , subq_5.user__last_login_ts__extract_day + , subq_5.user__last_login_ts__extract_dow + , subq_5.user__last_login_ts__extract_doy + , subq_5.user__archived_at__hour + , subq_5.user__archived_at__day + , subq_5.user__archived_at__week + , subq_5.user__archived_at__month + , subq_5.user__archived_at__quarter + , subq_5.user__archived_at__year + , subq_5.user__archived_at__extract_year + , subq_5.user__archived_at__extract_quarter + , subq_5.user__archived_at__extract_month + , subq_5.user__archived_at__extract_day + , subq_5.user__archived_at__extract_dow + , subq_5.user__archived_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.user + , subq_5.home_state + , subq_5.user__home_state FROM ( -- Metric Time Dimension 'created_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.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.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.last_profile_edit_ts__millisecond - , subq_5.last_profile_edit_ts__second - , subq_5.last_profile_edit_ts__minute - , subq_5.last_profile_edit_ts__hour - , subq_5.last_profile_edit_ts__day - , subq_5.last_profile_edit_ts__week - , subq_5.last_profile_edit_ts__month - , subq_5.last_profile_edit_ts__quarter - , subq_5.last_profile_edit_ts__year - , subq_5.last_profile_edit_ts__extract_year - , subq_5.last_profile_edit_ts__extract_quarter - , subq_5.last_profile_edit_ts__extract_month - , subq_5.last_profile_edit_ts__extract_day - , subq_5.last_profile_edit_ts__extract_dow - , subq_5.last_profile_edit_ts__extract_doy - , subq_5.bio_added_ts__second - , subq_5.bio_added_ts__minute - , subq_5.bio_added_ts__hour - , subq_5.bio_added_ts__day - , subq_5.bio_added_ts__week - , subq_5.bio_added_ts__month - , subq_5.bio_added_ts__quarter - , subq_5.bio_added_ts__year - , subq_5.bio_added_ts__extract_year - , subq_5.bio_added_ts__extract_quarter - , subq_5.bio_added_ts__extract_month - , subq_5.bio_added_ts__extract_day - , subq_5.bio_added_ts__extract_dow - , subq_5.bio_added_ts__extract_doy - , subq_5.last_login_ts__minute - , subq_5.last_login_ts__hour - , subq_5.last_login_ts__day - , subq_5.last_login_ts__week - , subq_5.last_login_ts__month - , subq_5.last_login_ts__quarter - , subq_5.last_login_ts__year - , subq_5.last_login_ts__extract_year - , subq_5.last_login_ts__extract_quarter - , subq_5.last_login_ts__extract_month - , subq_5.last_login_ts__extract_day - , subq_5.last_login_ts__extract_dow - , subq_5.last_login_ts__extract_doy - , subq_5.archived_at__hour - , subq_5.archived_at__day - , subq_5.archived_at__week - , subq_5.archived_at__month - , subq_5.archived_at__quarter - , subq_5.archived_at__year - , subq_5.archived_at__extract_year - , subq_5.archived_at__extract_quarter - , subq_5.archived_at__extract_month - , subq_5.archived_at__extract_day - , subq_5.archived_at__extract_dow - , subq_5.archived_at__extract_doy - , subq_5.user__ds__day - , subq_5.user__ds__week - , subq_5.user__ds__month - , subq_5.user__ds__quarter - , subq_5.user__ds__year - , subq_5.user__ds__extract_year - , subq_5.user__ds__extract_quarter - , subq_5.user__ds__extract_month - , subq_5.user__ds__extract_day - , subq_5.user__ds__extract_dow - , subq_5.user__ds__extract_doy - , subq_5.user__created_at__day - , subq_5.user__created_at__week - , subq_5.user__created_at__month - , subq_5.user__created_at__quarter - , subq_5.user__created_at__year - , subq_5.user__created_at__extract_year - , subq_5.user__created_at__extract_quarter - , subq_5.user__created_at__extract_month - , subq_5.user__created_at__extract_day - , subq_5.user__created_at__extract_dow - , subq_5.user__created_at__extract_doy - , subq_5.user__ds_partitioned__day - , subq_5.user__ds_partitioned__week - , subq_5.user__ds_partitioned__month - , subq_5.user__ds_partitioned__quarter - , subq_5.user__ds_partitioned__year - , subq_5.user__ds_partitioned__extract_year - , subq_5.user__ds_partitioned__extract_quarter - , subq_5.user__ds_partitioned__extract_month - , subq_5.user__ds_partitioned__extract_day - , subq_5.user__ds_partitioned__extract_dow - , subq_5.user__ds_partitioned__extract_doy - , subq_5.user__last_profile_edit_ts__millisecond - , subq_5.user__last_profile_edit_ts__second - , subq_5.user__last_profile_edit_ts__minute - , subq_5.user__last_profile_edit_ts__hour - , subq_5.user__last_profile_edit_ts__day - , subq_5.user__last_profile_edit_ts__week - , subq_5.user__last_profile_edit_ts__month - , subq_5.user__last_profile_edit_ts__quarter - , subq_5.user__last_profile_edit_ts__year - , subq_5.user__last_profile_edit_ts__extract_year - , subq_5.user__last_profile_edit_ts__extract_quarter - , subq_5.user__last_profile_edit_ts__extract_month - , subq_5.user__last_profile_edit_ts__extract_day - , subq_5.user__last_profile_edit_ts__extract_dow - , subq_5.user__last_profile_edit_ts__extract_doy - , subq_5.user__bio_added_ts__second - , subq_5.user__bio_added_ts__minute - , subq_5.user__bio_added_ts__hour - , subq_5.user__bio_added_ts__day - , subq_5.user__bio_added_ts__week - , subq_5.user__bio_added_ts__month - , subq_5.user__bio_added_ts__quarter - , subq_5.user__bio_added_ts__year - , subq_5.user__bio_added_ts__extract_year - , subq_5.user__bio_added_ts__extract_quarter - , subq_5.user__bio_added_ts__extract_month - , subq_5.user__bio_added_ts__extract_day - , subq_5.user__bio_added_ts__extract_dow - , subq_5.user__bio_added_ts__extract_doy - , subq_5.user__last_login_ts__minute - , subq_5.user__last_login_ts__hour - , subq_5.user__last_login_ts__day - , subq_5.user__last_login_ts__week - , subq_5.user__last_login_ts__month - , subq_5.user__last_login_ts__quarter - , subq_5.user__last_login_ts__year - , subq_5.user__last_login_ts__extract_year - , subq_5.user__last_login_ts__extract_quarter - , subq_5.user__last_login_ts__extract_month - , subq_5.user__last_login_ts__extract_day - , subq_5.user__last_login_ts__extract_dow - , subq_5.user__last_login_ts__extract_doy - , subq_5.user__archived_at__hour - , subq_5.user__archived_at__day - , subq_5.user__archived_at__week - , subq_5.user__archived_at__month - , subq_5.user__archived_at__quarter - , subq_5.user__archived_at__year - , subq_5.user__archived_at__extract_year - , subq_5.user__archived_at__extract_quarter - , subq_5.user__archived_at__extract_month - , subq_5.user__archived_at__extract_day - , subq_5.user__archived_at__extract_dow - , subq_5.user__archived_at__extract_doy - , subq_5.created_at__day AS metric_time__day - , subq_5.created_at__week AS metric_time__week - , subq_5.created_at__month AS metric_time__month - , subq_5.created_at__quarter AS metric_time__quarter - , subq_5.created_at__year AS metric_time__year - , subq_5.created_at__extract_year AS metric_time__extract_year - , subq_5.created_at__extract_quarter AS metric_time__extract_quarter - , subq_5.created_at__extract_month AS metric_time__extract_month - , subq_5.created_at__extract_day AS metric_time__extract_day - , subq_5.created_at__extract_dow AS metric_time__extract_dow - , subq_5.created_at__extract_doy AS metric_time__extract_doy - , subq_5.user - , subq_5.home_state - , subq_5.user__home_state - , subq_5.new_users + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.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.last_profile_edit_ts__millisecond + , subq_4.last_profile_edit_ts__second + , subq_4.last_profile_edit_ts__minute + , subq_4.last_profile_edit_ts__hour + , subq_4.last_profile_edit_ts__day + , subq_4.last_profile_edit_ts__week + , subq_4.last_profile_edit_ts__month + , subq_4.last_profile_edit_ts__quarter + , subq_4.last_profile_edit_ts__year + , subq_4.last_profile_edit_ts__extract_year + , subq_4.last_profile_edit_ts__extract_quarter + , subq_4.last_profile_edit_ts__extract_month + , subq_4.last_profile_edit_ts__extract_day + , subq_4.last_profile_edit_ts__extract_dow + , subq_4.last_profile_edit_ts__extract_doy + , subq_4.bio_added_ts__second + , subq_4.bio_added_ts__minute + , subq_4.bio_added_ts__hour + , subq_4.bio_added_ts__day + , subq_4.bio_added_ts__week + , subq_4.bio_added_ts__month + , subq_4.bio_added_ts__quarter + , subq_4.bio_added_ts__year + , subq_4.bio_added_ts__extract_year + , subq_4.bio_added_ts__extract_quarter + , subq_4.bio_added_ts__extract_month + , subq_4.bio_added_ts__extract_day + , subq_4.bio_added_ts__extract_dow + , subq_4.bio_added_ts__extract_doy + , subq_4.last_login_ts__minute + , subq_4.last_login_ts__hour + , subq_4.last_login_ts__day + , subq_4.last_login_ts__week + , subq_4.last_login_ts__month + , subq_4.last_login_ts__quarter + , subq_4.last_login_ts__year + , subq_4.last_login_ts__extract_year + , subq_4.last_login_ts__extract_quarter + , subq_4.last_login_ts__extract_month + , subq_4.last_login_ts__extract_day + , subq_4.last_login_ts__extract_dow + , subq_4.last_login_ts__extract_doy + , subq_4.archived_at__hour + , subq_4.archived_at__day + , subq_4.archived_at__week + , subq_4.archived_at__month + , subq_4.archived_at__quarter + , subq_4.archived_at__year + , subq_4.archived_at__extract_year + , subq_4.archived_at__extract_quarter + , subq_4.archived_at__extract_month + , subq_4.archived_at__extract_day + , subq_4.archived_at__extract_dow + , subq_4.archived_at__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__created_at__day + , subq_4.user__created_at__week + , subq_4.user__created_at__month + , subq_4.user__created_at__quarter + , subq_4.user__created_at__year + , subq_4.user__created_at__extract_year + , subq_4.user__created_at__extract_quarter + , subq_4.user__created_at__extract_month + , subq_4.user__created_at__extract_day + , subq_4.user__created_at__extract_dow + , subq_4.user__created_at__extract_doy + , subq_4.user__ds_partitioned__day + , subq_4.user__ds_partitioned__week + , subq_4.user__ds_partitioned__month + , subq_4.user__ds_partitioned__quarter + , subq_4.user__ds_partitioned__year + , subq_4.user__ds_partitioned__extract_year + , subq_4.user__ds_partitioned__extract_quarter + , subq_4.user__ds_partitioned__extract_month + , subq_4.user__ds_partitioned__extract_day + , subq_4.user__ds_partitioned__extract_dow + , subq_4.user__ds_partitioned__extract_doy + , subq_4.user__last_profile_edit_ts__millisecond + , subq_4.user__last_profile_edit_ts__second + , subq_4.user__last_profile_edit_ts__minute + , subq_4.user__last_profile_edit_ts__hour + , subq_4.user__last_profile_edit_ts__day + , subq_4.user__last_profile_edit_ts__week + , subq_4.user__last_profile_edit_ts__month + , subq_4.user__last_profile_edit_ts__quarter + , subq_4.user__last_profile_edit_ts__year + , subq_4.user__last_profile_edit_ts__extract_year + , subq_4.user__last_profile_edit_ts__extract_quarter + , subq_4.user__last_profile_edit_ts__extract_month + , subq_4.user__last_profile_edit_ts__extract_day + , subq_4.user__last_profile_edit_ts__extract_dow + , subq_4.user__last_profile_edit_ts__extract_doy + , subq_4.user__bio_added_ts__second + , subq_4.user__bio_added_ts__minute + , subq_4.user__bio_added_ts__hour + , subq_4.user__bio_added_ts__day + , subq_4.user__bio_added_ts__week + , subq_4.user__bio_added_ts__month + , subq_4.user__bio_added_ts__quarter + , subq_4.user__bio_added_ts__year + , subq_4.user__bio_added_ts__extract_year + , subq_4.user__bio_added_ts__extract_quarter + , subq_4.user__bio_added_ts__extract_month + , subq_4.user__bio_added_ts__extract_day + , subq_4.user__bio_added_ts__extract_dow + , subq_4.user__bio_added_ts__extract_doy + , subq_4.user__last_login_ts__minute + , subq_4.user__last_login_ts__hour + , subq_4.user__last_login_ts__day + , subq_4.user__last_login_ts__week + , subq_4.user__last_login_ts__month + , subq_4.user__last_login_ts__quarter + , subq_4.user__last_login_ts__year + , subq_4.user__last_login_ts__extract_year + , subq_4.user__last_login_ts__extract_quarter + , subq_4.user__last_login_ts__extract_month + , subq_4.user__last_login_ts__extract_day + , subq_4.user__last_login_ts__extract_dow + , subq_4.user__last_login_ts__extract_doy + , subq_4.user__archived_at__hour + , subq_4.user__archived_at__day + , subq_4.user__archived_at__week + , subq_4.user__archived_at__month + , subq_4.user__archived_at__quarter + , subq_4.user__archived_at__year + , subq_4.user__archived_at__extract_year + , subq_4.user__archived_at__extract_quarter + , subq_4.user__archived_at__extract_month + , subq_4.user__archived_at__extract_day + , subq_4.user__archived_at__extract_dow + , subq_4.user__archived_at__extract_doy + , subq_4.created_at__day AS metric_time__day + , subq_4.created_at__week AS metric_time__week + , subq_4.created_at__month AS metric_time__month + , subq_4.created_at__quarter AS metric_time__quarter + , subq_4.created_at__year AS metric_time__year + , subq_4.created_at__extract_year AS metric_time__extract_year + , subq_4.created_at__extract_quarter AS metric_time__extract_quarter + , subq_4.created_at__extract_month AS metric_time__extract_month + , subq_4.created_at__extract_day AS metric_time__extract_day + , subq_4.created_at__extract_dow AS metric_time__extract_dow + , subq_4.created_at__extract_doy AS metric_time__extract_doy + , subq_4.user + , subq_4.home_state + , subq_4.user__home_state + , subq_4.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -1284,21 +1372,21 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON - subq_4.user = subq_7.user - ) subq_8 - ) subq_9 + subq_3.user = subq_6.user + ) subq_7 + ) subq_8 ON ( - subq_2.listing = subq_9.listing + subq_1.listing = subq_8.listing ) AND ( - subq_2.ds_partitioned__day = subq_9.user__ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.user__ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.listing__user__bio_added_ts__minute -) subq_12 + subq_10.listing__user__bio_added_ts__minute +) subq_11 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql index d93a3918ba..43eaac5acd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_simple_metric_with_joined_sub_daily_dimension__plan0_optimized.sql @@ -3,18 +3,17 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute - , SUM(subq_15.bookings) AS bookings + subq_20.user__bio_added_ts__minute AS listing__user__bio_added_ts__minute + , SUM(subq_13.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 -) subq_15 +) subq_13 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__ds_partitioned__day', 'user__bio_added_ts__minute', 'listing'] @@ -27,12 +26,12 @@ LEFT OUTER JOIN ( ***************************.dim_users users_ds_source_src_28000 ON listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id -) subq_22 +) subq_20 ON ( - subq_15.listing = subq_22.listing + subq_13.listing = subq_20.listing ) AND ( - subq_15.ds_partitioned__day = subq_22.user__ds_partitioned__day + subq_13.ds_partitioned__day = subq_20.user__ds_partitioned__day ) GROUP BY - subq_22.user__bio_added_ts__minute + subq_20.user__bio_added_ts__minute diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 35c3eed167..3217f83f85 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index f0945b5733..c954dc18c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql index 7e751ecf4f..c6f2147023 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS FLOAT64) / CAST(NULLIF(subq_16.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS FLOAT64) / CAST(NULLIF(subq_17.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_3 - ) subq_4 - ) subq_5 - GROUP BY - user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_2 + ) subq_3 + ) subq_4 + GROUP BY + user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , GENERATE_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , GENERATE_UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , buys_source_src_28000.user_id AS buyers - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day - , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week - , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month - , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month - , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter - , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , buys_source_src_28000.user_id AS buyers + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , DATETIME_TRUNC(buys_source_src_28000.ds, day) AS buy__ds__day + , DATETIME_TRUNC(buys_source_src_28000.ds, isoweek) AS buy__ds__week + , DATETIME_TRUNC(buys_source_src_28000.ds, month) AS buy__ds__month + , DATETIME_TRUNC(buys_source_src_28000.ds, quarter) AS buy__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(buys_source_src_28000.ds_month, month) AS buy__ds_month__month + , DATETIME_TRUNC(buys_source_src_28000.ds_month, quarter) AS buy__ds_month__quarter + , DATETIME_TRUNC(buys_source_src_28000.ds_month, year) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY user - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + user + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql index 0e9d17577e..1508b54428 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS FLOAT64) / CAST(NULLIF(subq_42.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS FLOAT64) / CAST(NULLIF(subq_39.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY user - ) subq_31 + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY user - ) subq_41 + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY user - ) subq_42 + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql index 155981c2ff..5bfad36ee4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 5494591133..1eaa9b7aba 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listing__user - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql index f743c3ea12..c38766278a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS third_hop_ds__day - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS third_hop_ds__week - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS third_hop_ds__month - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS third_hop_ds__quarter - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS third_hop_ds__extract_dow - , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS customer_third_hop_id__third_hop_ds__day - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS customer_third_hop_id__third_hop_ds__week - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS customer_third_hop_id__third_hop_ds__month - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS customer_third_hop_id__third_hop_ds__quarter - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS third_hop_ds__day + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS third_hop_ds__week + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS third_hop_ds__month + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS third_hop_ds__quarter + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS third_hop_ds__extract_dow + , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS customer_third_hop_id__third_hop_ds__day + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS customer_third_hop_id__third_hop_ds__week + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS customer_third_hop_id__third_hop_ds__month + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS customer_third_hop_id__third_hop_ds__quarter + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS ds__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS ds__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS account_id__ds__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS account_id__ds__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS account_id__ds__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS account_id__ds__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS account_id__ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS ds__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS ds__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS account_id__ds__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS account_id__ds__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS account_id__ds__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS account_id__ds__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS account_id__ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , bridge_table_src_22000.extra_dim + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS bridge_account__ds_partitioned__day + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS bridge_account__ds_partitioned__month + , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter + , DATETIME_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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , bridge_table_src_22000.extra_dim - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) AS bridge_account__ds_partitioned__day - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, month) AS bridge_account__ds_partitioned__month - , DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter - , DATETIME_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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_id__acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_id__acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_id__acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_id__acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_id__acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_third_hop_id__acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_third_hop_id__acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_third_hop_id__acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_third_hop_id__acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_id__acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_id__acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_id__acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_id__acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_id__acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_third_hop_id__acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_third_hop_id__acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_third_hop_id__acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_third_hop_id__acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql index 60ede6bbce..db737b1986 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_35.ds_partitioned__day + DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_30.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_third_hop_id - ) subq_40 + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql index f9bd59a56c..1ed2f0023d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS third_hop_ds__day - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS third_hop_ds__week - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS third_hop_ds__month - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS third_hop_ds__quarter - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS third_hop_ds__extract_dow - , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS customer_third_hop_id__third_hop_ds__day - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS customer_third_hop_id__third_hop_ds__week - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS customer_third_hop_id__third_hop_ds__month - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS customer_third_hop_id__third_hop_ds__quarter - , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS third_hop_ds__day + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS third_hop_ds__week + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS third_hop_ds__month + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS third_hop_ds__quarter + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS third_hop_ds__extract_dow + , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, day) AS customer_third_hop_id__third_hop_ds__day + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, isoweek) AS customer_third_hop_id__third_hop_ds__week + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, month) AS customer_third_hop_id__third_hop_ds__month + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, quarter) AS customer_third_hop_id__third_hop_ds__quarter + , DATETIME_TRUNC(third_hop_table_src_22000.third_hop_ds, year) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , IF(EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) = 1, 7, EXTRACT(dayofweek FROM third_hop_table_src_22000.third_hop_ds) - 1) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(dayofyear FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_id__acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_id__acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_id__acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_id__acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_id__acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_third_hop_id__acquired_ds__day - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_third_hop_id__acquired_ds__week - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_third_hop_id__acquired_ds__month - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_third_hop_id__acquired_ds__quarter - , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_id__acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_id__acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_id__acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_id__acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_id__acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, day) AS customer_third_hop_id__acquired_ds__day + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, isoweek) AS customer_third_hop_id__acquired_ds__week + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, month) AS customer_third_hop_id__acquired_ds__month + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, quarter) AS customer_third_hop_id__acquired_ds__quarter + , DATETIME_TRUNC(customer_other_data_src_22000.acquired_ds, year) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , IF(EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) = 1, 7, EXTRACT(dayofweek FROM customer_other_data_src_22000.acquired_ds) - 1) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(dayofyear FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql index ae7d821d26..2f6c9a13a5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql index 171d08c509..952462a601 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql index 34fe1f900f..5d2a06d7b5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql index d74b9ae977..c2022ffbfc 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(created_at, day) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql index bceb3143d0..b48103ee38 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - revenue_src_28000.revenue AS txn_revenue - , DATETIME_TRUNC(revenue_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(revenue_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day - , DATETIME_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week - , DATETIME_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month - , DATETIME_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter - , DATETIME_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_3 - ) subq_4 - ) subq_5 - GROUP BY - user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + revenue_src_28000.revenue AS txn_revenue + , DATETIME_TRUNC(revenue_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(revenue_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(revenue_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(revenue_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(revenue_src_28000.created_at, day) AS revenue_instance__ds__day + , DATETIME_TRUNC(revenue_src_28000.created_at, isoweek) AS revenue_instance__ds__week + , DATETIME_TRUNC(revenue_src_28000.created_at, month) AS revenue_instance__ds__month + , DATETIME_TRUNC(revenue_src_28000.created_at, quarter) AS revenue_instance__ds__quarter + , DATETIME_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_2 + ) subq_3 + ) subq_4 + GROUP BY + user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index aa49927a1c..cb8bf327ce 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql index 049db657ff..f2200a151d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter - , DATETIME_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_8 - ) subq_9 - ) subq_10 - GROUP BY - listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - listing - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter + , DATETIME_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_7 + ) subq_8 + ) subq_9 + GROUP BY + listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + listing + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index 37ce69c405..825dfd04b5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY listing - ) subq_34 - ) subq_36 + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql index 3f2383b230..e098fec181 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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_8 + ) subq_9 + ) subq_10 + GROUP BY + listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 76e0386b97..9824108ee4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql index 712702655f..d9d836e846 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS FLOAT64) / CAST(NULLIF(subq_12.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS FLOAT64) / CAST(NULLIF(subq_13.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_8 - ) subq_9 - ) subq_10 - GROUP BY - listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - listing - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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_7 + ) subq_8 + ) subq_9 + GROUP BY + listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + listing + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index d42cddafe1..6fe17f2270 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS FLOAT64) / CAST(NULLIF(subq_28.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS FLOAT64) / CAST(NULLIF(subq_25.bookers, 0) AS FLOAT64) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql index b81eb9a775..cda4b8ec8e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ) subq_5 - GROUP BY - listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/BigQuery/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 52c7168b62..79f27ebdf3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 93d184feee..4b33a96ff2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql index 064154fa99..b1e6d59930 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - subq_15.user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - COALESCE(subq_6.user, subq_16.user) - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + subq_14.user + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + COALESCE(subq_5.user, subq_15.user) + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql index ec7e653e7b..7981369c33 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS DOUBLE) / CAST(NULLIF(subq_39.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY - subq_30.user - ) subq_31 + subq_27.user + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY - subq_38.user - ) subq_41 + subq_35.user + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY - COALESCE(subq_31.user, subq_41.user) - ) subq_42 + COALESCE(subq_28.user, subq_38.user) + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql index 923c6ef78b..abace8568d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_4 ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + subq_8.listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 8a2de81699..2ee174977a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql index 43f4771e88..26e6866fd3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , 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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , 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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - subq_14.account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + subq_12.account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql index 97117da92a..bdcc03a79c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_30.ds_partitioned__day ) GROUP BY - subq_35.customer_id__customer_third_hop_id - ) subq_40 + subq_30.customer_id__customer_third_hop_id + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql index 84b93f01f6..8c8be5f063 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + subq_5.customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql index 690c3af2fa..24f32dc58b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql index fc6f75f09e..2670479341 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql index 91e5941c55..4c630ac86c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day -) subq_13 + subq_10.metric_time__day +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 21fd1f7db3..6099c2233b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 740aeef1ab..3e578af81e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 2b782589e8..aedda5822a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql index b44efcd0dc..1ee42c6070 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , 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_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index e5f6bf61fb..7bb1c0f3a7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY - COALESCE(subq_28.listing, subq_33.listing) - ) subq_34 - ) subq_36 + COALESCE(subq_25.listing, subq_30.listing) + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql index b5c9b3dc42..c65ee051a0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 - ) subq_10 - ) subq_11 - GROUP BY - subq_11.listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_8 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 767f0b3fea..0a8508c1ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql index a6bebe31f3..aa9ad9d38b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS DOUBLE) / CAST(NULLIF(subq_12.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 4847f003cd..c013b4d97f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS DOUBLE) / CAST(NULLIF(subq_28.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS DOUBLE) / CAST(NULLIF(subq_25.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql index 3c41302368..7271c1d83c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Databricks/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index a0a48965f4..971a1f3425 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 93d184feee..4b33a96ff2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql index 40436a2c9d..009f4efd73 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , GEN_RANDOM_UUID() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , GEN_RANDOM_UUID() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - subq_15.user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - COALESCE(subq_6.user, subq_16.user) - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + subq_14.user + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + COALESCE(subq_5.user, subq_15.user) + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql index cab65b635d..fd62594e7a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_39.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY - subq_30.user - ) subq_31 + subq_27.user + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY - subq_38.user - ) subq_41 + subq_35.user + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY - COALESCE(subq_31.user, subq_41.user) - ) subq_42 + COALESCE(subq_28.user, subq_38.user) + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql index 646daaaf6e..d98a7df7cc 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_4 ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + subq_8.listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 8a2de81699..2ee174977a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql index 5ce70b6587..6fb6f7252d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , 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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , 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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - subq_14.account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + subq_12.account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql index 97117da92a..bdcc03a79c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_30.ds_partitioned__day ) GROUP BY - subq_35.customer_id__customer_third_hop_id - ) subq_40 + subq_30.customer_id__customer_third_hop_id + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql index a57e5675da..9fb74c6e09 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(isodow FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(isodow FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + subq_5.customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql index b10efd3e3b..1e4b7dfdf1 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql index fc6f75f09e..2670479341 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql index 3e41750e11..0eba535244 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day -) subq_13 + subq_10.metric_time__day +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 21fd1f7db3..6099c2233b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql index d7686e6bf8..41694f0f94 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 2b782589e8..aedda5822a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql index cfac984d0b..89746caea3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , 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_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index e5f6bf61fb..7bb1c0f3a7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY - COALESCE(subq_28.listing, subq_33.listing) - ) subq_34 - ) subq_36 + COALESCE(subq_25.listing, subq_30.listing) + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql index 7df39950a3..da7fdf2ca5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 - ) subq_10 - ) subq_11 - GROUP BY - subq_11.listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_8 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 767f0b3fea..0a8508c1ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql index ba88cd95f5..3c87ca82b5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 085dab5637..8ff640f011 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_28.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_25.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql index 97ec04b930..e930bc30c5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Postgres/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 819212083f..80ea78a3b4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 93d184feee..4b33a96ff2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql index 9a08a748f2..c2b052f5ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.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_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - subq_15.user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - COALESCE(subq_6.user, subq_16.user) - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + subq_14.user + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + COALESCE(subq_5.user, subq_15.user) + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql index 1e8fbccbd8..dec277d828 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_39.visits, 0) AS DOUBLE PRECISION) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY - subq_30.user - ) subq_31 + subq_27.user + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY - subq_38.user - ) subq_41 + subq_35.user + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY - COALESCE(subq_31.user, subq_41.user) - ) subq_42 + COALESCE(subq_28.user, subq_38.user) + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql index e9cf44d859..cb68a478d2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_4 ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + subq_8.listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 8a2de81699..2ee174977a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql index a77e86ef93..1b53560738 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , 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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , 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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - subq_14.account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + subq_12.account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql index 97117da92a..bdcc03a79c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_30.ds_partitioned__day ) GROUP BY - subq_35.customer_id__customer_third_hop_id - ) subq_40 + subq_30.customer_id__customer_third_hop_id + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql index 8a031c83ea..bec29a0b16 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , CASE WHEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) = 0 THEN EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) + 7 ELSE EXTRACT(dow FROM third_hop_table_src_22000.third_hop_ds) END AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , CASE WHEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) = 0 THEN EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) + 7 ELSE EXTRACT(dow FROM customer_other_data_src_22000.acquired_ds) END AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + subq_5.customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql index be6c880698..82899255bb 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql index fc6f75f09e..2670479341 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql index 76198dc32c..0923cdad58 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day -) subq_13 + subq_10.metric_time__day +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 21fd1f7db3..6099c2233b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 2ff47a9733..086d5f502d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 2b782589e8..aedda5822a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql index e4fa9aadce..1314332624 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , 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_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index e5f6bf61fb..7bb1c0f3a7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY - COALESCE(subq_28.listing, subq_33.listing) - ) subq_34 - ) subq_36 + COALESCE(subq_25.listing, subq_30.listing) + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql index e2d1dad354..6c5ab6be73 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 - ) subq_10 - ) subq_11 - GROUP BY - subq_11.listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_8 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 767f0b3fea..0a8508c1ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql index 3efd088ba3..5fb61f3777 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 085dab5637..8ff640f011 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_28.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_25.bookers, 0) AS DOUBLE PRECISION) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql index a60ecf02a8..c96a14a492 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Redshift/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index a81183bee9..bade6351d5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 93d184feee..4b33a96ff2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql index bc498aa0c6..9b6a4a8e04 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , UUID_STRING() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , UUID_STRING() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - subq_15.user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - COALESCE(subq_6.user, subq_16.user) - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + subq_14.user + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + COALESCE(subq_5.user, subq_15.user) + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql index 11138aa3ef..39e457ef9a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS DOUBLE) / CAST(NULLIF(subq_39.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY - subq_30.user - ) subq_31 + subq_27.user + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY - subq_38.user - ) subq_41 + subq_35.user + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY - COALESCE(subq_31.user, subq_41.user) - ) subq_42 + COALESCE(subq_28.user, subq_38.user) + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql index b07fd00394..2971e555b6 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_4 ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + subq_8.listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 8a2de81699..2ee174977a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql index 7a335a0428..9ca112a5a4 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , 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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , 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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - subq_14.account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + subq_12.account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql index 97117da92a..bdcc03a79c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_30.ds_partitioned__day ) GROUP BY - subq_35.customer_id__customer_third_hop_id - ) subq_40 + subq_30.customer_id__customer_third_hop_id + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql index 50b5010e98..a7560f5fbf 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(dayofweekiso FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(dayofweekiso FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + subq_5.customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql index f00d017f9a..469c8c395b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql index fc6f75f09e..2670479341 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql index 8f424b5bee..9a63113178 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day -) subq_13 + subq_10.metric_time__day +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 21fd1f7db3..6099c2233b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 1379c1c1c9..ae321fc99b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 2b782589e8..aedda5822a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql index e96c04b505..9d91118e21 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , 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_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index e5f6bf61fb..7bb1c0f3a7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY - COALESCE(subq_28.listing, subq_33.listing) - ) subq_34 - ) subq_36 + COALESCE(subq_25.listing, subq_30.listing) + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql index 84eafa76d9..fa1fccb8c1 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 - ) subq_10 - ) subq_11 - GROUP BY - subq_11.listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_8 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 767f0b3fea..0a8508c1ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql index 406289ee16..3044226f24 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS DOUBLE) / CAST(NULLIF(subq_12.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 4847f003cd..c013b4d97f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS DOUBLE) / CAST(NULLIF(subq_28.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS DOUBLE) / CAST(NULLIF(subq_25.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql index 53f7e6dfa0..1df667ea27 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Snowflake/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql index 3234da955f..4996f2f570 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.guest__booking_value - , subq_10.bookers + 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.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.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.guest__booking_value + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest__booking_value'] + -- Join Standard Outputs SELECT - subq_9.guest__booking_value - , subq_9.bookers + subq_7.guest__booking_value AS guest__booking_value + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.guest__booking_value AS guest__booking_value - , subq_2.guest AS guest - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'guest'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.guest - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['guest', 'guest__booking_value'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['guest', 'guest__booking_value'] + SELECT + subq_6.guest + , subq_6.guest__booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.guest - , subq_7.guest__booking_value + subq_5.guest + , subq_5.booking_value AS guest__booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.guest - , subq_6.booking_value AS guest__booking_value + subq_4.guest + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'guest'] SELECT - subq_5.guest - , SUM(subq_5.booking_value) AS booking_value + subq_3.guest + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'guest'] + -- Metric Time Dimension 'ds' SELECT - subq_4.guest - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.guest - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.guest = subq_8.guest - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.guest + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.guest = subq_7.guest + ) subq_8 WHERE guest__booking_value > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql index 93d184feee..4b33a96ff2 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_by_metric_in_same_semantic_model_as_queried_metric__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'guest__booking_value'] SELECT - subq_22.guest__booking_value AS guest__booking_value - , subq_16.bookers AS bookers + subq_19.guest__booking_value AS guest__booking_value + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'guest'] SELECT guest_id AS guest , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY guest_id - ) subq_22 + ) subq_19 ON - subq_16.guest = subq_22.guest -) subq_24 + subq_13.guest = subq_19.guest +) subq_20 WHERE guest__booking_value > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql index c1da875146..37467c2be3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0.sql @@ -1,592 +1,711 @@ -- Compute Metrics via Expressions SELECT - subq_24.listings + subq_22.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_23.listings) AS listings + SUM(subq_21.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_22.listings + subq_20.listings FROM ( -- Constrain Output with WHERE SELECT - subq_21.user__visit_buy_conversion_rate - , subq_21.listings + 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.metric_time__day + , subq_19.metric_time__week + , subq_19.metric_time__month + , subq_19.metric_time__quarter + , subq_19.metric_time__year + , subq_19.metric_time__extract_year + , subq_19.metric_time__extract_quarter + , subq_19.metric_time__extract_month + , subq_19.metric_time__extract_day + , subq_19.metric_time__extract_dow + , subq_19.metric_time__extract_doy + , subq_19.listing + , subq_19.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.user__visit_buy_conversion_rate + , subq_19.listings + , subq_19.largest_listing + , subq_19.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] + -- Join Standard Outputs SELECT - subq_20.user__visit_buy_conversion_rate - , subq_20.listings + subq_18.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_19.user__visit_buy_conversion_rate AS user__visit_buy_conversion_rate - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__visit_buy_conversion_rate'] + SELECT + subq_17.user + , subq_17.user__visit_buy_conversion_rate + FROM ( + -- Compute Metrics via Expressions SELECT - subq_18.user - , subq_18.user__visit_buy_conversion_rate + subq_16.user + , CAST(subq_16.buys AS DOUBLE) / CAST(NULLIF(subq_16.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_17.user - , CAST(subq_17.buys AS DOUBLE) / CAST(NULLIF(subq_17.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + COALESCE(subq_5.user, subq_15.user) AS user + , MAX(subq_5.visits) AS visits + , MAX(subq_15.buys) AS buys FROM ( - -- Combine Aggregated Outputs + -- Aggregate Measures SELECT - COALESCE(subq_6.user, subq_16.user) AS user - , MAX(subq_6.visits) AS visits - , MAX(subq_16.buys) AS buys + subq_4.user + , SUM(subq_4.visits) AS visits FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['visits', 'user'] SELECT - subq_5.user - , SUM(subq_5.visits) AS visits + subq_3.user + , subq_3.visits FROM ( - -- Pass Only Elements: ['visits', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.visits + 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.visit__ds__day + , subq_2.visit__ds__week + , subq_2.visit__ds__month + , subq_2.visit__ds__quarter + , subq_2.visit__ds__year + , subq_2.visit__ds__extract_year + , subq_2.visit__ds__extract_quarter + , subq_2.visit__ds__extract_month + , subq_2.visit__ds__extract_day + , subq_2.visit__ds__extract_dow + , subq_2.visit__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.session + , subq_2.visit__user + , subq_2.visit__session + , subq_2.referrer_id + , subq_2.visit__referrer_id + , subq_2.visits + , subq_2.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_3.visit__ds__week - , subq_3.visit__ds__month - , subq_3.visit__ds__quarter - , subq_3.visit__ds__year - , subq_3.visit__ds__extract_year - , subq_3.visit__ds__extract_quarter - , subq_3.visit__ds__extract_month - , subq_3.visit__ds__extract_day - , subq_3.visit__ds__extract_dow - , subq_3.visit__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.session - , subq_3.visit__user - , subq_3.visit__session - , subq_3.referrer_id - , subq_3.visit__referrer_id - , subq_3.visits - , subq_3.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - FULL OUTER JOIN ( - -- Aggregate Measures + 1 AS visits + , 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + FULL OUTER JOIN ( + -- Aggregate Measures + SELECT + subq_14.user + , SUM(subq_14.buys) AS buys + FROM ( + -- Pass Only Elements: ['buys', 'user'] SELECT - subq_15.user - , SUM(subq_15.buys) AS buys + subq_13.user + , subq_13.buys FROM ( - -- Pass Only Elements: ['buys', 'user'] + -- Find conversions for user within the range of INF SELECT - subq_14.user - , subq_14.buys + subq_12.metric_time__day + , subq_12.user + , subq_12.buys + , subq_12.visits FROM ( - -- Find conversions for user within the range of INF - SELECT - subq_13.metric_time__day - , subq_13.user - , subq_13.buys - , subq_13.visits + -- Dedupe the fanout with mf_internal_uuid in the conversion data set + SELECT DISTINCT + FIRST_VALUE(subq_8.visits) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS visits + , FIRST_VALUE(subq_8.metric_time__day) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS metric_time__day + , FIRST_VALUE(subq_8.user) OVER ( + PARTITION BY + subq_11.user + , subq_11.metric_time__day + , subq_11.mf_internal_uuid + ORDER BY subq_8.metric_time__day DESC + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING + ) AS user + , subq_11.mf_internal_uuid AS mf_internal_uuid + , subq_11.buys AS buys FROM ( - -- Dedupe the fanout with mf_internal_uuid in the conversion data set - SELECT DISTINCT - FIRST_VALUE(subq_9.visits) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS visits - , FIRST_VALUE(subq_9.metric_time__day) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS metric_time__day - , FIRST_VALUE(subq_9.user) OVER ( - PARTITION BY - subq_12.user - , subq_12.metric_time__day - , subq_12.mf_internal_uuid - ORDER BY subq_9.metric_time__day DESC - ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING - ) AS user - , subq_12.mf_internal_uuid AS mf_internal_uuid - , subq_12.buys AS buys + -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + SELECT + subq_7.metric_time__day + , subq_7.user + , subq_7.visits FROM ( - -- Pass Only Elements: ['visits', 'metric_time__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_8.metric_time__day - , subq_8.user - , subq_8.visits + subq_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.visit__ds__day + , subq_6.visit__ds__week + , subq_6.visit__ds__month + , subq_6.visit__ds__quarter + , subq_6.visit__ds__year + , subq_6.visit__ds__extract_year + , subq_6.visit__ds__extract_quarter + , subq_6.visit__ds__extract_month + , subq_6.visit__ds__extract_day + , subq_6.visit__ds__extract_dow + , subq_6.visit__ds__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.user + , subq_6.session + , subq_6.visit__user + , subq_6.visit__session + , subq_6.referrer_id + , subq_6.visit__referrer_id + , subq_6.visits + , subq_6.visitors FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'visits_source' 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.visit__ds__day - , subq_7.visit__ds__week - , subq_7.visit__ds__month - , subq_7.visit__ds__quarter - , subq_7.visit__ds__year - , subq_7.visit__ds__extract_year - , subq_7.visit__ds__extract_quarter - , subq_7.visit__ds__extract_month - , subq_7.visit__ds__extract_day - , subq_7.visit__ds__extract_dow - , subq_7.visit__ds__extract_doy - , subq_7.ds__day AS metric_time__day - , subq_7.ds__week AS metric_time__week - , subq_7.ds__month AS metric_time__month - , subq_7.ds__quarter AS metric_time__quarter - , subq_7.ds__year AS metric_time__year - , subq_7.ds__extract_year AS metric_time__extract_year - , subq_7.ds__extract_quarter AS metric_time__extract_quarter - , subq_7.ds__extract_month AS metric_time__extract_month - , subq_7.ds__extract_day AS metric_time__extract_day - , subq_7.ds__extract_dow AS metric_time__extract_dow - , subq_7.ds__extract_doy AS metric_time__extract_doy - , subq_7.user - , subq_7.session - , subq_7.visit__user - , subq_7.visit__session - , subq_7.referrer_id - , subq_7.visit__referrer_id - , subq_7.visits - , subq_7.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , 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_7 - ) subq_8 - ) subq_9 - INNER JOIN ( - -- Add column with generated UUID + 1 AS visits + , 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_6 + ) subq_7 + ) subq_8 + INNER JOIN ( + -- Add column with generated UUID + 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_month__month + , subq_10.ds_month__quarter + , subq_10.ds_month__year + , subq_10.ds_month__extract_year + , subq_10.ds_month__extract_quarter + , subq_10.ds_month__extract_month + , subq_10.buy__ds__day + , subq_10.buy__ds__week + , subq_10.buy__ds__month + , subq_10.buy__ds__quarter + , subq_10.buy__ds__year + , subq_10.buy__ds__extract_year + , subq_10.buy__ds__extract_quarter + , subq_10.buy__ds__extract_month + , subq_10.buy__ds__extract_day + , subq_10.buy__ds__extract_dow + , subq_10.buy__ds__extract_doy + , subq_10.buy__ds_month__month + , subq_10.buy__ds_month__quarter + , subq_10.buy__ds_month__year + , subq_10.buy__ds_month__extract_year + , subq_10.buy__ds_month__extract_quarter + , subq_10.buy__ds_month__extract_month + , subq_10.metric_time__day + , subq_10.metric_time__week + , subq_10.metric_time__month + , subq_10.metric_time__quarter + , subq_10.metric_time__year + , 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.user + , subq_10.session_id + , subq_10.buy__user + , subq_10.buy__session_id + , subq_10.buys + , subq_10.buyers + , uuid() AS mf_internal_uuid + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_11.ds__day - , subq_11.ds__week - , subq_11.ds__month - , subq_11.ds__quarter - , subq_11.ds__year - , subq_11.ds__extract_year - , subq_11.ds__extract_quarter - , subq_11.ds__extract_month - , subq_11.ds__extract_day - , subq_11.ds__extract_dow - , subq_11.ds__extract_doy - , subq_11.ds_month__month - , subq_11.ds_month__quarter - , subq_11.ds_month__year - , subq_11.ds_month__extract_year - , subq_11.ds_month__extract_quarter - , subq_11.ds_month__extract_month - , subq_11.buy__ds__day - , subq_11.buy__ds__week - , subq_11.buy__ds__month - , subq_11.buy__ds__quarter - , subq_11.buy__ds__year - , subq_11.buy__ds__extract_year - , subq_11.buy__ds__extract_quarter - , subq_11.buy__ds__extract_month - , subq_11.buy__ds__extract_day - , subq_11.buy__ds__extract_dow - , subq_11.buy__ds__extract_doy - , subq_11.buy__ds_month__month - , subq_11.buy__ds_month__quarter - , subq_11.buy__ds_month__year - , subq_11.buy__ds_month__extract_year - , subq_11.buy__ds_month__extract_quarter - , subq_11.buy__ds_month__extract_month - , subq_11.metric_time__day - , subq_11.metric_time__week - , subq_11.metric_time__month - , subq_11.metric_time__quarter - , subq_11.metric_time__year - , subq_11.metric_time__extract_year - , subq_11.metric_time__extract_quarter - , subq_11.metric_time__extract_month - , subq_11.metric_time__extract_day - , subq_11.metric_time__extract_dow - , subq_11.metric_time__extract_doy - , subq_11.user - , subq_11.session_id - , subq_11.buy__user - , subq_11.buy__session_id - , subq_11.buys - , subq_11.buyers - , uuid() AS mf_internal_uuid + subq_9.ds__day + , subq_9.ds__week + , subq_9.ds__month + , subq_9.ds__quarter + , subq_9.ds__year + , subq_9.ds__extract_year + , subq_9.ds__extract_quarter + , subq_9.ds__extract_month + , subq_9.ds__extract_day + , subq_9.ds__extract_dow + , subq_9.ds__extract_doy + , subq_9.ds_month__month + , subq_9.ds_month__quarter + , subq_9.ds_month__year + , subq_9.ds_month__extract_year + , subq_9.ds_month__extract_quarter + , subq_9.ds_month__extract_month + , subq_9.buy__ds__day + , subq_9.buy__ds__week + , subq_9.buy__ds__month + , subq_9.buy__ds__quarter + , subq_9.buy__ds__year + , subq_9.buy__ds__extract_year + , subq_9.buy__ds__extract_quarter + , subq_9.buy__ds__extract_month + , subq_9.buy__ds__extract_day + , subq_9.buy__ds__extract_dow + , subq_9.buy__ds__extract_doy + , subq_9.buy__ds_month__month + , subq_9.buy__ds_month__quarter + , subq_9.buy__ds_month__year + , subq_9.buy__ds_month__extract_year + , subq_9.buy__ds_month__extract_quarter + , subq_9.buy__ds_month__extract_month + , subq_9.ds__day AS metric_time__day + , subq_9.ds__week AS metric_time__week + , subq_9.ds__month AS metric_time__month + , subq_9.ds__quarter AS metric_time__quarter + , subq_9.ds__year AS metric_time__year + , subq_9.ds__extract_year AS metric_time__extract_year + , subq_9.ds__extract_quarter AS metric_time__extract_quarter + , subq_9.ds__extract_month AS metric_time__extract_month + , subq_9.ds__extract_day AS metric_time__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_id + , subq_9.buy__user + , subq_9.buy__session_id + , subq_9.buys + , subq_9.buyers FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'buys_source' 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_month__month - , subq_10.ds_month__quarter - , subq_10.ds_month__year - , subq_10.ds_month__extract_year - , subq_10.ds_month__extract_quarter - , subq_10.ds_month__extract_month - , subq_10.buy__ds__day - , subq_10.buy__ds__week - , subq_10.buy__ds__month - , subq_10.buy__ds__quarter - , subq_10.buy__ds__year - , subq_10.buy__ds__extract_year - , subq_10.buy__ds__extract_quarter - , subq_10.buy__ds__extract_month - , subq_10.buy__ds__extract_day - , subq_10.buy__ds__extract_dow - , subq_10.buy__ds__extract_doy - , subq_10.buy__ds_month__month - , subq_10.buy__ds_month__quarter - , subq_10.buy__ds_month__year - , subq_10.buy__ds_month__extract_year - , subq_10.buy__ds_month__extract_quarter - , subq_10.buy__ds_month__extract_month - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session_id - , subq_10.buy__user - , subq_10.buy__session_id - , subq_10.buys - , subq_10.buyers - FROM ( - -- Read Elements From Semantic Model 'buys_source' - SELECT - 1 AS buys - , 1 AS buys_month - , 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('month', buys_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month - , 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 - , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month - , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter - , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year - , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year - , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter - , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month - , 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_10 - ) subq_11 - ) subq_12 - ON - ( - subq_9.user = subq_12.user - ) AND ( - (subq_9.metric_time__day <= subq_12.metric_time__day) - ) - ) subq_13 - ) subq_14 - ) subq_15 - GROUP BY - subq_15.user - ) subq_16 - ON - subq_6.user = subq_16.user + 1 AS buys + , 1 AS buys_month + , 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('month', buys_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS ds_month__extract_month + , 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 + , DATE_TRUNC('month', buys_source_src_28000.ds_month) AS buy__ds_month__month + , DATE_TRUNC('quarter', buys_source_src_28000.ds_month) AS buy__ds_month__quarter + , DATE_TRUNC('year', buys_source_src_28000.ds_month) AS buy__ds_month__year + , EXTRACT(year FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_year + , EXTRACT(quarter FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_quarter + , EXTRACT(month FROM buys_source_src_28000.ds_month) AS buy__ds_month__extract_month + , 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_9 + ) subq_10 + ) subq_11 + ON + ( + subq_8.user = subq_11.user + ) AND ( + (subq_8.metric_time__day <= subq_11.metric_time__day) + ) + ) subq_12 + ) subq_13 + ) subq_14 GROUP BY - COALESCE(subq_6.user, subq_16.user) - ) subq_17 - ) subq_18 - ) subq_19 - ON - subq_2.user = subq_19.user - ) subq_20 - ) subq_21 + subq_14.user + ) subq_15 + ON + subq_5.user = subq_15.user + GROUP BY + COALESCE(subq_5.user, subq_15.user) + ) subq_16 + ) subq_17 + ) subq_18 + ON + subq_1.user = subq_18.user + ) subq_19 WHERE user__visit_buy_conversion_rate > 2 - ) subq_22 - ) subq_23 -) subq_24 + ) subq_20 + ) subq_21 +) subq_22 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql index d3be510ab0..875b6c43f5 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_filter_with_conversion_metric__plan0_optimized.sql @@ -6,29 +6,27 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate'] SELECT - CAST(subq_42.buys AS DOUBLE) / CAST(NULLIF(subq_42.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate - , subq_27.listings AS listings + CAST(subq_39.buys AS DOUBLE) / CAST(NULLIF(subq_39.visits, 0) AS DOUBLE) AS user__visit_buy_conversion_rate + , subq_24.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_31.user, subq_41.user) AS user - , MAX(subq_31.visits) AS visits - , MAX(subq_41.buys) AS buys + COALESCE(subq_28.user, subq_38.user) AS user + , MAX(subq_28.visits) AS visits + , MAX(subq_38.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_30.user + subq_27.user , SUM(visits) AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' @@ -38,46 +36,46 @@ FROM ( user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_30 + ) subq_27 GROUP BY - subq_30.user - ) subq_31 + subq_27.user + ) subq_28 FULL OUTER JOIN ( -- Find conversions for user within the range of INF -- Pass Only Elements: ['buys', 'user'] -- Aggregate Measures SELECT - subq_38.user + subq_35.user , SUM(buys) AS buys FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_34.visits) OVER ( + FIRST_VALUE(subq_31.visits) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_34.metric_time__day) OVER ( + , FIRST_VALUE(subq_31.metric_time__day) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_34.user) OVER ( + , FIRST_VALUE(subq_31.user) OVER ( PARTITION BY - subq_37.user - , subq_37.metric_time__day - , subq_37.mf_internal_uuid - ORDER BY subq_34.metric_time__day DESC + subq_34.user + , subq_34.metric_time__day + , subq_34.mf_internal_uuid + ORDER BY subq_31.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_37.mf_internal_uuid AS mf_internal_uuid - , subq_37.buys AS buys + , subq_34.mf_internal_uuid AS mf_internal_uuid + , subq_34.buys AS buys FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -87,7 +85,7 @@ FROM ( , user_id AS user , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_34 + ) subq_31 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -98,23 +96,23 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_37 + ) subq_34 ON ( - subq_34.user = subq_37.user + subq_31.user = subq_34.user ) AND ( - (subq_34.metric_time__day <= subq_37.metric_time__day) + (subq_31.metric_time__day <= subq_34.metric_time__day) ) - ) subq_38 + ) subq_35 GROUP BY - subq_38.user - ) subq_41 + subq_35.user + ) subq_38 ON - subq_31.user = subq_41.user + subq_28.user = subq_38.user GROUP BY - COALESCE(subq_31.user, subq_41.user) - ) subq_42 + COALESCE(subq_28.user, subq_38.user) + ) subq_39 ON - subq_27.user = subq_42.user -) subq_46 + subq_24.user = subq_39.user +) subq_42 WHERE user__visit_buy_conversion_rate > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql index 34aa606047..536bb518f0 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0.sql @@ -1,548 +1,758 @@ -- Compute Metrics via Expressions SELECT - subq_18.listings + subq_15.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_17.listings) AS listings + SUM(subq_14.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_16.listings + subq_13.listings FROM ( -- Constrain Output with WHERE SELECT - subq_15.user__listing__user__average_booking_value - , subq_15.listings + 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.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.listing + , subq_12.user + , subq_12.listing__user + , subq_12.user__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.user__listing__user__average_booking_value + , subq_12.listings + , subq_12.largest_listing + , subq_12.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] + -- Join Standard Outputs SELECT - subq_14.user__listing__user__average_booking_value - , subq_14.listings + subq_11.listing__user AS user__listing__user + , subq_11.listing__user__average_booking_value AS user__listing__user__average_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_13.listing__user AS user__listing__user - , subq_13.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing__user', 'listing__user__average_booking_value'] + SELECT + subq_10.listing__user + , subq_10.listing__user__average_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_12.listing__user - , subq_12.listing__user__average_booking_value + subq_9.listing__user + , subq_9.average_booking_value AS listing__user__average_booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_11.listing__user - , subq_11.average_booking_value AS listing__user__average_booking_value + subq_8.listing__user + , AVG(subq_8.average_booking_value) AS average_booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['average_booking_value', 'listing__user'] SELECT - subq_10.listing__user - , AVG(subq_10.average_booking_value) AS average_booking_value + subq_7.listing__user + , subq_7.average_booking_value FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__user'] + -- Join Standard Outputs SELECT - subq_9.listing__user - , subq_9.average_booking_value + subq_6.user AS listing__user + , 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.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.paid_at__day AS paid_at__day + , subq_3.paid_at__week AS paid_at__week + , subq_3.paid_at__month AS paid_at__month + , subq_3.paid_at__quarter AS paid_at__quarter + , subq_3.paid_at__year AS paid_at__year + , subq_3.paid_at__extract_year AS paid_at__extract_year + , subq_3.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_3.paid_at__extract_month AS paid_at__extract_month + , subq_3.paid_at__extract_day AS paid_at__extract_day + , subq_3.paid_at__extract_dow AS paid_at__extract_dow + , subq_3.paid_at__extract_doy AS paid_at__extract_doy + , subq_3.booking__ds__day AS booking__ds__day + , subq_3.booking__ds__week AS booking__ds__week + , subq_3.booking__ds__month AS booking__ds__month + , subq_3.booking__ds__quarter AS booking__ds__quarter + , subq_3.booking__ds__year AS booking__ds__year + , subq_3.booking__ds__extract_year AS booking__ds__extract_year + , subq_3.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_3.booking__ds__extract_month AS booking__ds__extract_month + , subq_3.booking__ds__extract_day AS booking__ds__extract_day + , subq_3.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_3.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_3.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_3.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_3.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_3.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_3.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_3.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_3.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_3.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_3.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_3.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_3.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_3.booking__paid_at__day AS booking__paid_at__day + , subq_3.booking__paid_at__week AS booking__paid_at__week + , subq_3.booking__paid_at__month AS booking__paid_at__month + , subq_3.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_3.booking__paid_at__year AS booking__paid_at__year + , subq_3.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_3.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_3.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_3.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_3.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_3.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.listing AS listing + , subq_3.guest AS guest + , subq_3.host AS host + , subq_3.booking__listing AS booking__listing + , subq_3.booking__guest AS booking__guest + , subq_3.booking__host AS booking__host + , subq_3.is_instant AS is_instant + , subq_3.booking__is_instant AS booking__is_instant + , subq_3.bookings AS bookings + , subq_3.instant_bookings AS instant_bookings + , subq_3.booking_value AS booking_value + , subq_3.max_booking_value AS max_booking_value + , subq_3.min_booking_value AS min_booking_value + , subq_3.bookers AS bookers + , subq_3.average_booking_value AS average_booking_value + , subq_3.referred_bookings AS referred_bookings + , subq_3.median_booking_value AS median_booking_value + , subq_3.booking_value_p99 AS booking_value_p99 + , subq_3.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_3.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_3.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user AS listing__user - , subq_5.listing AS listing - , subq_5.average_booking_value AS 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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_4.listing - , subq_4.average_booking_value + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'user'] + SELECT + subq_5.listing + , subq_5.user + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.ds__day AS metric_time__day + , subq_4.ds__week AS metric_time__week + , subq_4.ds__month AS metric_time__month + , subq_4.ds__quarter AS metric_time__quarter + , subq_4.ds__year AS metric_time__year + , subq_4.ds__extract_year AS metric_time__extract_year + , subq_4.ds__extract_quarter AS metric_time__extract_quarter + , subq_4.ds__extract_month AS metric_time__extract_month + , subq_4.ds__extract_day AS metric_time__extract_day + , subq_4.ds__extract_dow AS metric_time__extract_dow + , subq_4.ds__extract_doy AS metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 ) subq_4 ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'user'] - SELECT - subq_7.listing - , subq_7.user - 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing__user - ) subq_11 - ) subq_12 - ) subq_13 - ON - subq_2.user = subq_13.listing__user - ) subq_14 - ) subq_15 + ) subq_6 + ON + subq_3.listing = subq_6.listing + ) subq_7 + ) subq_8 + GROUP BY + subq_8.listing__user + ) subq_9 + ) subq_10 + ) subq_11 + ON + subq_1.user = subq_11.listing__user + ) subq_12 WHERE user__listing__user__average_booking_value > 1 - ) subq_16 - ) subq_17 -) subq_18 + ) subq_13 + ) subq_14 +) subq_15 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql index 8a2de81699..2ee174977a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_group_by_has_local_entity_prefix__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__listing__user__average_booking_value'] SELECT - subq_32.listing__user__average_booking_value AS user__listing__user__average_booking_value - , subq_21.listings AS listings + subq_27.listing__user__average_booking_value AS user__listing__user__average_booking_value + , subq_17.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 + ) subq_17 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['average_booking_value', 'listing__user'] @@ -35,8 +33,8 @@ FROM ( bookings_source_src_28000.listing_id = listings_latest_src_28000.listing_id GROUP BY listings_latest_src_28000.user_id - ) subq_32 + ) subq_27 ON - subq_21.user = subq_32.listing__user -) subq_34 + subq_17.user = subq_27.listing__user +) subq_28 WHERE user__listing__user__average_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql index 7221218118..03fd42b5c8 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0.sql @@ -1,694 +1,803 @@ -- Compute Metrics via Expressions SELECT - subq_22.third_hop_count + subq_19.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_21.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_18.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_20.third_hop_count + subq_17.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_19.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_19.third_hop_count + subq_16.third_hop_ds__day + , subq_16.third_hop_ds__week + , subq_16.third_hop_ds__month + , subq_16.third_hop_ds__quarter + , subq_16.third_hop_ds__year + , subq_16.third_hop_ds__extract_year + , subq_16.third_hop_ds__extract_quarter + , subq_16.third_hop_ds__extract_month + , subq_16.third_hop_ds__extract_day + , subq_16.third_hop_ds__extract_dow + , subq_16.third_hop_ds__extract_doy + , subq_16.customer_third_hop_id__third_hop_ds__day + , subq_16.customer_third_hop_id__third_hop_ds__week + , subq_16.customer_third_hop_id__third_hop_ds__month + , subq_16.customer_third_hop_id__third_hop_ds__quarter + , subq_16.customer_third_hop_id__third_hop_ds__year + , subq_16.customer_third_hop_id__third_hop_ds__extract_year + , subq_16.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_16.customer_third_hop_id__third_hop_ds__extract_month + , subq_16.customer_third_hop_id__third_hop_ds__extract_day + , subq_16.customer_third_hop_id__third_hop_ds__extract_dow + , subq_16.customer_third_hop_id__third_hop_ds__extract_doy + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.metric_time__extract_doy + , subq_16.customer_third_hop_id + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_16.value + , subq_16.customer_third_hop_id__value + , subq_16.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_16.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] + -- Join Standard Outputs SELECT - subq_18.customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_18.third_hop_count + subq_15.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id + , subq_15.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_17.account_id__customer_id__customer_third_hop_id AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id - , subq_17.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] + SELECT + subq_14.account_id__customer_id__customer_third_hop_id + , subq_14.account_id__customer_id__customer_third_hop_id__txn_count + FROM ( + -- Compute Metrics via Expressions SELECT - subq_16.account_id__customer_id__customer_third_hop_id - , subq_16.account_id__customer_id__customer_third_hop_id__txn_count + subq_13.account_id__customer_id__customer_third_hop_id + , subq_13.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_15.account_id__customer_id__customer_third_hop_id - , subq_15.txn_count AS account_id__customer_id__customer_third_hop_id__txn_count + subq_12.account_id__customer_id__customer_third_hop_id + , SUM(subq_12.txn_count) AS txn_count FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] SELECT - subq_14.account_id__customer_id__customer_third_hop_id - , SUM(subq_14.txn_count) AS txn_count + subq_11.account_id__customer_id__customer_third_hop_id + , subq_11.txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_third_hop_id'] + -- Join Standard Outputs SELECT - subq_13.account_id__customer_id__customer_third_hop_id - , subq_13.txn_count + subq_10.ds_partitioned__day AS account_id__ds_partitioned__day + , subq_10.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + , 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.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.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.account_id__ds__day AS account_id__ds__day + , subq_3.account_id__ds__week AS account_id__ds__week + , subq_3.account_id__ds__month AS account_id__ds__month + , subq_3.account_id__ds__quarter AS account_id__ds__quarter + , subq_3.account_id__ds__year AS account_id__ds__year + , subq_3.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_3.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_3.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_3.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_3.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_3.account_id__ds__extract_doy AS account_id__ds__extract_doy + , subq_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__extract_doy + , subq_3.account_id AS account_id + , subq_3.account_month AS account_month + , subq_3.account_id__account_month AS account_id__account_month + , subq_3.txn_count AS txn_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' + SELECT + 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.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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.account_id__ds__day + , subq_2.account_id__ds__week + , subq_2.account_id__ds__month + , subq_2.account_id__ds__quarter + , subq_2.account_id__ds__year + , subq_2.account_id__ds__extract_year + , subq_2.account_id__ds__extract_quarter + , subq_2.account_id__ds__extract_month + , subq_2.account_id__ds__extract_day + , subq_2.account_id__ds__extract_dow + , subq_2.account_id__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.account_month + , subq_2.account_id__account_month + , subq_2.txn_count + FROM ( + -- Read Elements From Semantic Model 'account_month_txns' + SELECT + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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_2 + ) subq_3 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] SELECT - subq_12.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_12.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id - , subq_5.ds_partitioned__day AS ds_partitioned__day - , subq_5.account_id AS account_id - , subq_5.txn_count AS txn_count + subq_9.ds_partitioned__day + , subq_9.account_id + , subq_9.customer_id__customer_third_hop_id FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Join Standard Outputs SELECT - subq_4.ds_partitioned__day - , subq_4.account_id - , subq_4.txn_count + subq_8.country AS customer_id__country + , subq_8.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country + , subq_8.acquired_ds__day AS customer_id__acquired_ds__day + , subq_8.acquired_ds__week AS customer_id__acquired_ds__week + , subq_8.acquired_ds__month AS customer_id__acquired_ds__month + , subq_8.acquired_ds__quarter AS customer_id__acquired_ds__quarter + , subq_8.acquired_ds__year AS customer_id__acquired_ds__year + , subq_8.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year + , subq_8.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter + , subq_8.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month + , subq_8.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day + , subq_8.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow + , subq_8.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy + , subq_8.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day + , subq_8.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week + , subq_8.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month + , subq_8.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter + , subq_8.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year + , subq_8.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year + , subq_8.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter + , subq_8.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month + , subq_8.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day + , subq_8.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow + , subq_8.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy + , subq_8.metric_time__day AS customer_id__metric_time__day + , subq_8.metric_time__week AS customer_id__metric_time__week + , subq_8.metric_time__month AS customer_id__metric_time__month + , subq_8.metric_time__quarter AS customer_id__metric_time__quarter + , subq_8.metric_time__year AS customer_id__metric_time__year + , subq_8.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_8.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_8.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_8.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_8.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_8.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , subq_8.customer_third_hop_id AS customer_id__customer_third_hop_id + , subq_8.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id + , subq_5.ds_partitioned__day AS ds_partitioned__day + , subq_5.ds_partitioned__week AS ds_partitioned__week + , subq_5.ds_partitioned__month AS ds_partitioned__month + , subq_5.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_5.ds_partitioned__year AS ds_partitioned__year + , subq_5.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_5.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_5.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_5.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_5.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_5.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_5.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_5.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_5.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_5.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_5.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_5.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_5.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day + , subq_5.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week + , subq_5.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month + , subq_5.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter + , subq_5.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year + , subq_5.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year + , subq_5.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter + , subq_5.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month + , subq_5.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day + , subq_5.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow + , subq_5.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy + , subq_5.metric_time__day AS metric_time__day + , subq_5.metric_time__week AS metric_time__week + , subq_5.metric_time__month AS metric_time__month + , subq_5.metric_time__quarter AS metric_time__quarter + , subq_5.metric_time__year AS metric_time__year + , subq_5.metric_time__extract_year AS metric_time__extract_year + , subq_5.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_5.metric_time__extract_month AS metric_time__extract_month + , subq_5.metric_time__extract_day AS metric_time__extract_day + , subq_5.metric_time__extract_dow AS metric_time__extract_dow + , subq_5.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.account_id AS account_id + , subq_5.customer_id AS customer_id + , subq_5.account_id__customer_id AS account_id__customer_id + , subq_5.bridge_account__account_id AS bridge_account__account_id + , subq_5.bridge_account__customer_id AS bridge_account__customer_id + , subq_5.extra_dim AS extra_dim + , subq_5.account_id__extra_dim AS account_id__extra_dim + , subq_5.bridge_account__extra_dim AS bridge_account__extra_dim + , subq_5.account_customer_combos AS account_customer_combos FROM ( - -- Metric Time Dimension 'ds' + -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.account_id__ds__day - , subq_3.account_id__ds__week - , subq_3.account_id__ds__month - , subq_3.account_id__ds__quarter - , subq_3.account_id__ds__year - , subq_3.account_id__ds__extract_year - , subq_3.account_id__ds__extract_quarter - , subq_3.account_id__ds__extract_month - , subq_3.account_id__ds__extract_day - , subq_3.account_id__ds__extract_dow - , subq_3.account_id__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.account_month - , subq_3.account_id__account_month - , subq_3.txn_count + 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.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.bridge_account__ds_partitioned__day + , subq_4.bridge_account__ds_partitioned__week + , subq_4.bridge_account__ds_partitioned__month + , subq_4.bridge_account__ds_partitioned__quarter + , subq_4.bridge_account__ds_partitioned__year + , subq_4.bridge_account__ds_partitioned__extract_year + , subq_4.bridge_account__ds_partitioned__extract_quarter + , subq_4.bridge_account__ds_partitioned__extract_month + , subq_4.bridge_account__ds_partitioned__extract_day + , subq_4.bridge_account__ds_partitioned__extract_dow + , subq_4.bridge_account__ds_partitioned__extract_doy + , subq_4.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_4.account_id + , subq_4.customer_id + , subq_4.account_id__customer_id + , subq_4.bridge_account__account_id + , subq_4.bridge_account__customer_id + , subq_4.extra_dim + , subq_4.account_id__extra_dim + , subq_4.bridge_account__extra_dim + , subq_4.account_customer_combos FROM ( - -- Read Elements From Semantic Model 'account_month_txns' + -- Read Elements From Semantic Model 'bridge_table' SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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_3 - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['ds_partitioned__day', 'account_id', 'customer_id__customer_third_hop_id'] - SELECT - subq_11.ds_partitioned__day - , subq_11.account_id - , subq_11.customer_id__customer_third_hop_id - FROM ( - -- Join Standard Outputs + account_id || customer_id AS account_customer_combos + , 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_4 + ) subq_5 + LEFT OUTER JOIN ( + -- Pass Only Elements: [ + -- 'country', + -- 'customer_id__country', + -- 'customer_third_hop_id__country', + -- 'acquired_ds__day', + -- 'acquired_ds__week', + -- 'acquired_ds__month', + -- 'acquired_ds__quarter', + -- 'acquired_ds__year', + -- 'acquired_ds__extract_year', + -- 'acquired_ds__extract_quarter', + -- 'acquired_ds__extract_month', + -- 'acquired_ds__extract_day', + -- 'acquired_ds__extract_dow', + -- 'acquired_ds__extract_doy', + -- 'customer_id__acquired_ds__day', + -- 'customer_id__acquired_ds__week', + -- 'customer_id__acquired_ds__month', + -- 'customer_id__acquired_ds__quarter', + -- 'customer_id__acquired_ds__year', + -- 'customer_id__acquired_ds__extract_year', + -- 'customer_id__acquired_ds__extract_quarter', + -- 'customer_id__acquired_ds__extract_month', + -- 'customer_id__acquired_ds__extract_day', + -- 'customer_id__acquired_ds__extract_dow', + -- 'customer_id__acquired_ds__extract_doy', + -- 'customer_third_hop_id__acquired_ds__day', + -- 'customer_third_hop_id__acquired_ds__week', + -- 'customer_third_hop_id__acquired_ds__month', + -- 'customer_third_hop_id__acquired_ds__quarter', + -- 'customer_third_hop_id__acquired_ds__year', + -- 'customer_third_hop_id__acquired_ds__extract_year', + -- 'customer_third_hop_id__acquired_ds__extract_quarter', + -- 'customer_third_hop_id__acquired_ds__extract_month', + -- 'customer_third_hop_id__acquired_ds__extract_day', + -- 'customer_third_hop_id__acquired_ds__extract_dow', + -- 'customer_third_hop_id__acquired_ds__extract_doy', + -- 'metric_time__day', + -- 'metric_time__week', + -- 'metric_time__month', + -- 'metric_time__quarter', + -- 'metric_time__year', + -- 'metric_time__extract_year', + -- 'metric_time__extract_quarter', + -- 'metric_time__extract_month', + -- 'metric_time__extract_day', + -- 'metric_time__extract_dow', + -- 'metric_time__extract_doy', + -- 'customer_id', + -- 'customer_third_hop_id', + -- 'customer_id__customer_third_hop_id', + -- 'customer_third_hop_id__customer_id', + -- ] SELECT - subq_10.country AS customer_id__country - , subq_10.customer_third_hop_id__country AS customer_id__customer_third_hop_id__country - , subq_10.acquired_ds__day AS customer_id__acquired_ds__day - , subq_10.acquired_ds__week AS customer_id__acquired_ds__week - , subq_10.acquired_ds__month AS customer_id__acquired_ds__month - , subq_10.acquired_ds__quarter AS customer_id__acquired_ds__quarter - , subq_10.acquired_ds__year AS customer_id__acquired_ds__year - , subq_10.acquired_ds__extract_year AS customer_id__acquired_ds__extract_year - , subq_10.acquired_ds__extract_quarter AS customer_id__acquired_ds__extract_quarter - , subq_10.acquired_ds__extract_month AS customer_id__acquired_ds__extract_month - , subq_10.acquired_ds__extract_day AS customer_id__acquired_ds__extract_day - , subq_10.acquired_ds__extract_dow AS customer_id__acquired_ds__extract_dow - , subq_10.acquired_ds__extract_doy AS customer_id__acquired_ds__extract_doy - , subq_10.customer_third_hop_id__acquired_ds__day AS customer_id__customer_third_hop_id__acquired_ds__day - , subq_10.customer_third_hop_id__acquired_ds__week AS customer_id__customer_third_hop_id__acquired_ds__week - , subq_10.customer_third_hop_id__acquired_ds__month AS customer_id__customer_third_hop_id__acquired_ds__month - , subq_10.customer_third_hop_id__acquired_ds__quarter AS customer_id__customer_third_hop_id__acquired_ds__quarter - , subq_10.customer_third_hop_id__acquired_ds__year AS customer_id__customer_third_hop_id__acquired_ds__year - , subq_10.customer_third_hop_id__acquired_ds__extract_year AS customer_id__customer_third_hop_id__acquired_ds__extract_year - , subq_10.customer_third_hop_id__acquired_ds__extract_quarter AS customer_id__customer_third_hop_id__acquired_ds__extract_quarter - , subq_10.customer_third_hop_id__acquired_ds__extract_month AS customer_id__customer_third_hop_id__acquired_ds__extract_month - , subq_10.customer_third_hop_id__acquired_ds__extract_day AS customer_id__customer_third_hop_id__acquired_ds__extract_day - , subq_10.customer_third_hop_id__acquired_ds__extract_dow AS customer_id__customer_third_hop_id__acquired_ds__extract_dow - , subq_10.customer_third_hop_id__acquired_ds__extract_doy AS customer_id__customer_third_hop_id__acquired_ds__extract_doy - , subq_10.metric_time__day AS customer_id__metric_time__day - , subq_10.metric_time__week AS customer_id__metric_time__week - , subq_10.metric_time__month AS customer_id__metric_time__month - , subq_10.metric_time__quarter AS customer_id__metric_time__quarter - , subq_10.metric_time__year AS customer_id__metric_time__year - , subq_10.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_10.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_10.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_10.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_10.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_10.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_10.customer_third_hop_id AS customer_id__customer_third_hop_id - , subq_10.customer_third_hop_id__customer_id AS customer_id__customer_third_hop_id__customer_id - , subq_7.ds_partitioned__day AS ds_partitioned__day - , subq_7.ds_partitioned__week AS ds_partitioned__week - , subq_7.ds_partitioned__month AS ds_partitioned__month - , subq_7.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_7.ds_partitioned__year AS ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_7.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_7.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_7.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_7.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_7.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_7.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_7.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_7.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_7.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_7.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_7.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_7.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_7.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_7.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_7.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_7.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_7.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_7.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_7.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_7.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_7.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_7.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_7.metric_time__day AS metric_time__day - , subq_7.metric_time__week AS metric_time__week - , subq_7.metric_time__month AS metric_time__month - , subq_7.metric_time__quarter AS metric_time__quarter - , subq_7.metric_time__year AS metric_time__year - , subq_7.metric_time__extract_year AS metric_time__extract_year - , subq_7.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_7.metric_time__extract_month AS metric_time__extract_month - , subq_7.metric_time__extract_day AS metric_time__extract_day - , subq_7.metric_time__extract_dow AS metric_time__extract_dow - , subq_7.metric_time__extract_doy AS metric_time__extract_doy - , subq_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_7.account_customer_combos AS account_customer_combos + subq_7.acquired_ds__day + , subq_7.acquired_ds__week + , subq_7.acquired_ds__month + , subq_7.acquired_ds__quarter + , subq_7.acquired_ds__year + , subq_7.acquired_ds__extract_year + , subq_7.acquired_ds__extract_quarter + , subq_7.acquired_ds__extract_month + , subq_7.acquired_ds__extract_day + , subq_7.acquired_ds__extract_dow + , subq_7.acquired_ds__extract_doy + , subq_7.customer_id__acquired_ds__day + , subq_7.customer_id__acquired_ds__week + , subq_7.customer_id__acquired_ds__month + , subq_7.customer_id__acquired_ds__quarter + , subq_7.customer_id__acquired_ds__year + , subq_7.customer_id__acquired_ds__extract_year + , subq_7.customer_id__acquired_ds__extract_quarter + , subq_7.customer_id__acquired_ds__extract_month + , subq_7.customer_id__acquired_ds__extract_day + , subq_7.customer_id__acquired_ds__extract_dow + , subq_7.customer_id__acquired_ds__extract_doy + , subq_7.customer_third_hop_id__acquired_ds__day + , subq_7.customer_third_hop_id__acquired_ds__week + , subq_7.customer_third_hop_id__acquired_ds__month + , subq_7.customer_third_hop_id__acquired_ds__quarter + , subq_7.customer_third_hop_id__acquired_ds__year + , subq_7.customer_third_hop_id__acquired_ds__extract_year + , subq_7.customer_third_hop_id__acquired_ds__extract_quarter + , subq_7.customer_third_hop_id__acquired_ds__extract_month + , subq_7.customer_third_hop_id__acquired_ds__extract_day + , subq_7.customer_third_hop_id__acquired_ds__extract_dow + , subq_7.customer_third_hop_id__acquired_ds__extract_doy + , subq_7.metric_time__day + , subq_7.metric_time__week + , subq_7.metric_time__month + , subq_7.metric_time__quarter + , subq_7.metric_time__year + , subq_7.metric_time__extract_year + , subq_7.metric_time__extract_quarter + , subq_7.metric_time__extract_month + , subq_7.metric_time__extract_day + , subq_7.metric_time__extract_dow + , subq_7.metric_time__extract_doy + , subq_7.customer_id + , subq_7.customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id + , subq_7.customer_third_hop_id__customer_id + , subq_7.country + , subq_7.customer_id__country + , subq_7.customer_third_hop_id__country FROM ( - -- Metric Time Dimension 'ds_partitioned' + -- Metric Time Dimension 'acquired_ds' SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.account_id__ds_partitioned__day - , subq_6.account_id__ds_partitioned__week - , subq_6.account_id__ds_partitioned__month - , subq_6.account_id__ds_partitioned__quarter - , subq_6.account_id__ds_partitioned__year - , subq_6.account_id__ds_partitioned__extract_year - , subq_6.account_id__ds_partitioned__extract_quarter - , subq_6.account_id__ds_partitioned__extract_month - , subq_6.account_id__ds_partitioned__extract_day - , subq_6.account_id__ds_partitioned__extract_dow - , subq_6.account_id__ds_partitioned__extract_doy - , subq_6.bridge_account__ds_partitioned__day - , subq_6.bridge_account__ds_partitioned__week - , subq_6.bridge_account__ds_partitioned__month - , subq_6.bridge_account__ds_partitioned__quarter - , subq_6.bridge_account__ds_partitioned__year - , subq_6.bridge_account__ds_partitioned__extract_year - , subq_6.bridge_account__ds_partitioned__extract_quarter - , subq_6.bridge_account__ds_partitioned__extract_month - , subq_6.bridge_account__ds_partitioned__extract_day - , subq_6.bridge_account__ds_partitioned__extract_dow - , subq_6.bridge_account__ds_partitioned__extract_doy - , subq_6.ds_partitioned__day AS metric_time__day - , subq_6.ds_partitioned__week AS metric_time__week - , subq_6.ds_partitioned__month AS metric_time__month - , subq_6.ds_partitioned__quarter AS metric_time__quarter - , subq_6.ds_partitioned__year AS metric_time__year - , subq_6.ds_partitioned__extract_year AS metric_time__extract_year - , subq_6.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_6.ds_partitioned__extract_month AS metric_time__extract_month - , subq_6.ds_partitioned__extract_day AS metric_time__extract_day - , subq_6.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_6.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_6.account_id + subq_6.acquired_ds__day + , subq_6.acquired_ds__week + , subq_6.acquired_ds__month + , subq_6.acquired_ds__quarter + , subq_6.acquired_ds__year + , subq_6.acquired_ds__extract_year + , subq_6.acquired_ds__extract_quarter + , subq_6.acquired_ds__extract_month + , subq_6.acquired_ds__extract_day + , subq_6.acquired_ds__extract_dow + , subq_6.acquired_ds__extract_doy + , subq_6.customer_id__acquired_ds__day + , subq_6.customer_id__acquired_ds__week + , subq_6.customer_id__acquired_ds__month + , subq_6.customer_id__acquired_ds__quarter + , subq_6.customer_id__acquired_ds__year + , subq_6.customer_id__acquired_ds__extract_year + , subq_6.customer_id__acquired_ds__extract_quarter + , subq_6.customer_id__acquired_ds__extract_month + , subq_6.customer_id__acquired_ds__extract_day + , subq_6.customer_id__acquired_ds__extract_dow + , subq_6.customer_id__acquired_ds__extract_doy + , subq_6.customer_third_hop_id__acquired_ds__day + , subq_6.customer_third_hop_id__acquired_ds__week + , subq_6.customer_third_hop_id__acquired_ds__month + , subq_6.customer_third_hop_id__acquired_ds__quarter + , subq_6.customer_third_hop_id__acquired_ds__year + , subq_6.customer_third_hop_id__acquired_ds__extract_year + , subq_6.customer_third_hop_id__acquired_ds__extract_quarter + , subq_6.customer_third_hop_id__acquired_ds__extract_month + , subq_6.customer_third_hop_id__acquired_ds__extract_day + , subq_6.customer_third_hop_id__acquired_ds__extract_dow + , subq_6.customer_third_hop_id__acquired_ds__extract_doy + , subq_6.acquired_ds__day AS metric_time__day + , subq_6.acquired_ds__week AS metric_time__week + , subq_6.acquired_ds__month AS metric_time__month + , subq_6.acquired_ds__quarter AS metric_time__quarter + , subq_6.acquired_ds__year AS metric_time__year + , subq_6.acquired_ds__extract_year AS metric_time__extract_year + , subq_6.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_6.acquired_ds__extract_month AS metric_time__extract_month + , subq_6.acquired_ds__extract_day AS metric_time__extract_day + , subq_6.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_6.acquired_ds__extract_doy AS metric_time__extract_doy , subq_6.customer_id - , subq_6.account_id__customer_id - , subq_6.bridge_account__account_id - , subq_6.bridge_account__customer_id - , subq_6.extra_dim - , subq_6.account_id__extra_dim - , subq_6.bridge_account__extra_dim - , subq_6.account_customer_combos + , subq_6.customer_third_hop_id + , subq_6.customer_id__customer_third_hop_id + , subq_6.customer_third_hop_id__customer_id + , subq_6.country + , subq_6.customer_id__country + , subq_6.customer_third_hop_id__country + , subq_6.customers_with_other_data FROM ( - -- Read Elements From Semantic Model 'bridge_table' + -- Read Elements From Semantic Model 'customer_other_data' SELECT - account_id || customer_id AS account_customer_combos - , 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 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 ) subq_6 ) subq_7 - LEFT OUTER JOIN ( - -- Pass Only Elements: [ - -- 'country', - -- 'customer_id__country', - -- 'customer_third_hop_id__country', - -- 'acquired_ds__day', - -- 'acquired_ds__week', - -- 'acquired_ds__month', - -- 'acquired_ds__quarter', - -- 'acquired_ds__year', - -- 'acquired_ds__extract_year', - -- 'acquired_ds__extract_quarter', - -- 'acquired_ds__extract_month', - -- 'acquired_ds__extract_day', - -- 'acquired_ds__extract_dow', - -- 'acquired_ds__extract_doy', - -- 'customer_id__acquired_ds__day', - -- 'customer_id__acquired_ds__week', - -- 'customer_id__acquired_ds__month', - -- 'customer_id__acquired_ds__quarter', - -- 'customer_id__acquired_ds__year', - -- 'customer_id__acquired_ds__extract_year', - -- 'customer_id__acquired_ds__extract_quarter', - -- 'customer_id__acquired_ds__extract_month', - -- 'customer_id__acquired_ds__extract_day', - -- 'customer_id__acquired_ds__extract_dow', - -- 'customer_id__acquired_ds__extract_doy', - -- 'customer_third_hop_id__acquired_ds__day', - -- 'customer_third_hop_id__acquired_ds__week', - -- 'customer_third_hop_id__acquired_ds__month', - -- 'customer_third_hop_id__acquired_ds__quarter', - -- 'customer_third_hop_id__acquired_ds__year', - -- 'customer_third_hop_id__acquired_ds__extract_year', - -- 'customer_third_hop_id__acquired_ds__extract_quarter', - -- 'customer_third_hop_id__acquired_ds__extract_month', - -- 'customer_third_hop_id__acquired_ds__extract_day', - -- 'customer_third_hop_id__acquired_ds__extract_dow', - -- 'customer_third_hop_id__acquired_ds__extract_doy', - -- 'metric_time__day', - -- 'metric_time__week', - -- 'metric_time__month', - -- 'metric_time__quarter', - -- 'metric_time__year', - -- 'metric_time__extract_year', - -- 'metric_time__extract_quarter', - -- 'metric_time__extract_month', - -- 'metric_time__extract_day', - -- 'metric_time__extract_dow', - -- 'metric_time__extract_doy', - -- 'customer_id', - -- 'customer_third_hop_id', - -- 'customer_id__customer_third_hop_id', - -- 'customer_third_hop_id__customer_id', - -- ] - SELECT - subq_9.acquired_ds__day - , subq_9.acquired_ds__week - , subq_9.acquired_ds__month - , subq_9.acquired_ds__quarter - , subq_9.acquired_ds__year - , subq_9.acquired_ds__extract_year - , subq_9.acquired_ds__extract_quarter - , subq_9.acquired_ds__extract_month - , subq_9.acquired_ds__extract_day - , subq_9.acquired_ds__extract_dow - , subq_9.acquired_ds__extract_doy - , subq_9.customer_id__acquired_ds__day - , subq_9.customer_id__acquired_ds__week - , subq_9.customer_id__acquired_ds__month - , subq_9.customer_id__acquired_ds__quarter - , subq_9.customer_id__acquired_ds__year - , subq_9.customer_id__acquired_ds__extract_year - , subq_9.customer_id__acquired_ds__extract_quarter - , subq_9.customer_id__acquired_ds__extract_month - , subq_9.customer_id__acquired_ds__extract_day - , subq_9.customer_id__acquired_ds__extract_dow - , subq_9.customer_id__acquired_ds__extract_doy - , subq_9.customer_third_hop_id__acquired_ds__day - , subq_9.customer_third_hop_id__acquired_ds__week - , subq_9.customer_third_hop_id__acquired_ds__month - , subq_9.customer_third_hop_id__acquired_ds__quarter - , subq_9.customer_third_hop_id__acquired_ds__year - , subq_9.customer_third_hop_id__acquired_ds__extract_year - , subq_9.customer_third_hop_id__acquired_ds__extract_quarter - , subq_9.customer_third_hop_id__acquired_ds__extract_month - , subq_9.customer_third_hop_id__acquired_ds__extract_day - , subq_9.customer_third_hop_id__acquired_ds__extract_dow - , subq_9.customer_third_hop_id__acquired_ds__extract_doy - , subq_9.metric_time__day - , subq_9.metric_time__week - , subq_9.metric_time__month - , subq_9.metric_time__quarter - , subq_9.metric_time__year - , subq_9.metric_time__extract_year - , subq_9.metric_time__extract_quarter - , subq_9.metric_time__extract_month - , subq_9.metric_time__extract_day - , subq_9.metric_time__extract_dow - , subq_9.metric_time__extract_doy - , subq_9.customer_id - , subq_9.customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id - , subq_9.customer_third_hop_id__customer_id - , subq_9.country - , subq_9.customer_id__country - , subq_9.customer_third_hop_id__country - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_8.acquired_ds__day - , subq_8.acquired_ds__week - , subq_8.acquired_ds__month - , subq_8.acquired_ds__quarter - , subq_8.acquired_ds__year - , subq_8.acquired_ds__extract_year - , subq_8.acquired_ds__extract_quarter - , subq_8.acquired_ds__extract_month - , subq_8.acquired_ds__extract_day - , subq_8.acquired_ds__extract_dow - , subq_8.acquired_ds__extract_doy - , subq_8.customer_id__acquired_ds__day - , subq_8.customer_id__acquired_ds__week - , subq_8.customer_id__acquired_ds__month - , subq_8.customer_id__acquired_ds__quarter - , subq_8.customer_id__acquired_ds__year - , subq_8.customer_id__acquired_ds__extract_year - , subq_8.customer_id__acquired_ds__extract_quarter - , subq_8.customer_id__acquired_ds__extract_month - , subq_8.customer_id__acquired_ds__extract_day - , subq_8.customer_id__acquired_ds__extract_dow - , subq_8.customer_id__acquired_ds__extract_doy - , subq_8.customer_third_hop_id__acquired_ds__day - , subq_8.customer_third_hop_id__acquired_ds__week - , subq_8.customer_third_hop_id__acquired_ds__month - , subq_8.customer_third_hop_id__acquired_ds__quarter - , subq_8.customer_third_hop_id__acquired_ds__year - , subq_8.customer_third_hop_id__acquired_ds__extract_year - , subq_8.customer_third_hop_id__acquired_ds__extract_quarter - , subq_8.customer_third_hop_id__acquired_ds__extract_month - , subq_8.customer_third_hop_id__acquired_ds__extract_day - , subq_8.customer_third_hop_id__acquired_ds__extract_dow - , subq_8.customer_third_hop_id__acquired_ds__extract_doy - , subq_8.acquired_ds__day AS metric_time__day - , subq_8.acquired_ds__week AS metric_time__week - , subq_8.acquired_ds__month AS metric_time__month - , subq_8.acquired_ds__quarter AS metric_time__quarter - , subq_8.acquired_ds__year AS metric_time__year - , subq_8.acquired_ds__extract_year AS metric_time__extract_year - , subq_8.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_8.acquired_ds__extract_month AS metric_time__extract_month - , subq_8.acquired_ds__extract_day AS metric_time__extract_day - , subq_8.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_8.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_8.customer_id - , subq_8.customer_third_hop_id - , subq_8.customer_id__customer_third_hop_id - , subq_8.customer_third_hop_id__customer_id - , subq_8.country - , subq_8.customer_id__country - , subq_8.customer_third_hop_id__country - , subq_8.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_7.customer_id = subq_10.customer_id - ) subq_11 - ) subq_12 - ON - ( - subq_5.account_id = subq_12.account_id - ) AND ( - subq_5.ds_partitioned__day = subq_12.ds_partitioned__day - ) - ) subq_13 - ) subq_14 - GROUP BY - subq_14.account_id__customer_id__customer_third_hop_id - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_2.customer_third_hop_id = subq_17.account_id__customer_id__customer_third_hop_id - ) subq_18 - ) subq_19 + ) subq_8 + ON + subq_5.customer_id = subq_8.customer_id + ) subq_9 + ) subq_10 + ON + ( + subq_3.account_id = subq_10.account_id + ) AND ( + subq_3.ds_partitioned__day = subq_10.ds_partitioned__day + ) + ) subq_11 + ) subq_12 + GROUP BY + subq_12.account_id__customer_id__customer_third_hop_id + ) subq_13 + ) subq_14 + ) subq_15 + ON + subq_1.customer_third_hop_id = subq_15.account_id__customer_id__customer_third_hop_id + ) subq_16 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 - ) subq_20 - ) subq_21 -) subq_22 + ) subq_17 + ) subq_18 +) subq_19 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql index 97117da92a..bdcc03a79c 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_multi_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_40.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count + subq_35.account_id__customer_id__customer_third_hop_id__txn_count AS customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -18,7 +17,7 @@ FROM ( -- Compute Metrics via Expressions -- Pass Only Elements: ['account_id__customer_id__customer_third_hop_id', 'account_id__customer_id__customer_third_hop_id__txn_count'] SELECT - subq_35.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id + subq_30.customer_id__customer_third_hop_id AS account_id__customer_id__customer_third_hop_id , SUM(account_month_txns_src_22000.txn_count) AS account_id__customer_id__customer_third_hop_id__txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -33,17 +32,17 @@ FROM ( ***************************.customer_other_data customer_other_data_src_22000 ON bridge_table_src_22000.customer_id = customer_other_data_src_22000.customer_id - ) subq_35 + ) subq_30 ON ( - account_month_txns_src_22000.account_id = subq_35.account_id + account_month_txns_src_22000.account_id = subq_30.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_35.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_30.ds_partitioned__day ) GROUP BY - subq_35.customer_id__customer_third_hop_id - ) subq_40 + subq_30.customer_id__customer_third_hop_id + ) subq_35 ON - third_hop_table_src_22000.customer_third_hop_id = subq_40.account_id__customer_id__customer_third_hop_id -) subq_42 + third_hop_table_src_22000.customer_third_hop_id = subq_35.account_id__customer_id__customer_third_hop_id +) subq_36 WHERE customer_third_hop_id__account_id__customer_id__customer_third_hop_id__txn_count > 2 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql index ad3df23fab..c02339224d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0.sql @@ -1,257 +1,359 @@ -- Compute Metrics via Expressions SELECT - subq_15.third_hop_count + subq_12.third_hop_count FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_14.third_hop_count) AS third_hop_count + COUNT(DISTINCT subq_11.third_hop_count) AS third_hop_count FROM ( -- Pass Only Elements: ['third_hop_count',] SELECT - subq_13.third_hop_count + subq_10.third_hop_count FROM ( -- Constrain Output with WHERE SELECT - subq_12.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_12.third_hop_count + subq_9.third_hop_ds__day + , subq_9.third_hop_ds__week + , subq_9.third_hop_ds__month + , subq_9.third_hop_ds__quarter + , subq_9.third_hop_ds__year + , subq_9.third_hop_ds__extract_year + , subq_9.third_hop_ds__extract_quarter + , subq_9.third_hop_ds__extract_month + , subq_9.third_hop_ds__extract_day + , subq_9.third_hop_ds__extract_dow + , subq_9.third_hop_ds__extract_doy + , subq_9.customer_third_hop_id__third_hop_ds__day + , subq_9.customer_third_hop_id__third_hop_ds__week + , subq_9.customer_third_hop_id__third_hop_ds__month + , subq_9.customer_third_hop_id__third_hop_ds__quarter + , subq_9.customer_third_hop_id__third_hop_ds__year + , subq_9.customer_third_hop_id__third_hop_ds__extract_year + , subq_9.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_9.customer_third_hop_id__third_hop_ds__extract_month + , subq_9.customer_third_hop_id__third_hop_ds__extract_day + , subq_9.customer_third_hop_id__third_hop_ds__extract_dow + , subq_9.customer_third_hop_id__third_hop_ds__extract_doy + , subq_9.metric_time__day + , subq_9.metric_time__week + , subq_9.metric_time__month + , subq_9.metric_time__quarter + , subq_9.metric_time__year + , subq_9.metric_time__extract_year + , subq_9.metric_time__extract_quarter + , subq_9.metric_time__extract_month + , subq_9.metric_time__extract_day + , subq_9.metric_time__extract_dow + , subq_9.metric_time__extract_doy + , subq_9.customer_third_hop_id + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id + , subq_9.value + , subq_9.customer_third_hop_id__value + , subq_9.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_9.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] + -- Join Standard Outputs SELECT - subq_11.customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_11.third_hop_count + subq_8.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id + , subq_8.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + , subq_1.third_hop_ds__day AS third_hop_ds__day + , subq_1.third_hop_ds__week AS third_hop_ds__week + , subq_1.third_hop_ds__month AS third_hop_ds__month + , subq_1.third_hop_ds__quarter AS third_hop_ds__quarter + , subq_1.third_hop_ds__year AS third_hop_ds__year + , subq_1.third_hop_ds__extract_year AS third_hop_ds__extract_year + , subq_1.third_hop_ds__extract_quarter AS third_hop_ds__extract_quarter + , subq_1.third_hop_ds__extract_month AS third_hop_ds__extract_month + , subq_1.third_hop_ds__extract_day AS third_hop_ds__extract_day + , subq_1.third_hop_ds__extract_dow AS third_hop_ds__extract_dow + , subq_1.third_hop_ds__extract_doy AS third_hop_ds__extract_doy + , subq_1.customer_third_hop_id__third_hop_ds__day AS customer_third_hop_id__third_hop_ds__day + , subq_1.customer_third_hop_id__third_hop_ds__week AS customer_third_hop_id__third_hop_ds__week + , subq_1.customer_third_hop_id__third_hop_ds__month AS customer_third_hop_id__third_hop_ds__month + , subq_1.customer_third_hop_id__third_hop_ds__quarter AS customer_third_hop_id__third_hop_ds__quarter + , subq_1.customer_third_hop_id__third_hop_ds__year AS customer_third_hop_id__third_hop_ds__year + , subq_1.customer_third_hop_id__third_hop_ds__extract_year AS customer_third_hop_id__third_hop_ds__extract_year + , subq_1.customer_third_hop_id__third_hop_ds__extract_quarter AS customer_third_hop_id__third_hop_ds__extract_quarter + , subq_1.customer_third_hop_id__third_hop_ds__extract_month AS customer_third_hop_id__third_hop_ds__extract_month + , subq_1.customer_third_hop_id__third_hop_ds__extract_day AS customer_third_hop_id__third_hop_ds__extract_day + , subq_1.customer_third_hop_id__third_hop_ds__extract_dow AS customer_third_hop_id__third_hop_ds__extract_dow + , subq_1.customer_third_hop_id__third_hop_ds__extract_doy AS customer_third_hop_id__third_hop_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.customer_third_hop_id AS customer_third_hop_id + , subq_1.value AS value + , subq_1.customer_third_hop_id__value AS customer_third_hop_id__value + , subq_1.third_hop_count AS third_hop_count FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'third_hop_ds' SELECT - subq_10.customer_id__customer_third_hop_id AS customer_third_hop_id__customer_id__customer_third_hop_id - , subq_10.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers - , subq_2.customer_third_hop_id AS customer_third_hop_id - , subq_2.third_hop_count AS third_hop_count + subq_0.third_hop_ds__day + , subq_0.third_hop_ds__week + , subq_0.third_hop_ds__month + , subq_0.third_hop_ds__quarter + , subq_0.third_hop_ds__year + , subq_0.third_hop_ds__extract_year + , subq_0.third_hop_ds__extract_quarter + , subq_0.third_hop_ds__extract_month + , subq_0.third_hop_ds__extract_day + , subq_0.third_hop_ds__extract_dow + , subq_0.third_hop_ds__extract_doy + , subq_0.customer_third_hop_id__third_hop_ds__day + , subq_0.customer_third_hop_id__third_hop_ds__week + , subq_0.customer_third_hop_id__third_hop_ds__month + , subq_0.customer_third_hop_id__third_hop_ds__quarter + , subq_0.customer_third_hop_id__third_hop_ds__year + , subq_0.customer_third_hop_id__third_hop_ds__extract_year + , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter + , subq_0.customer_third_hop_id__third_hop_ds__extract_month + , subq_0.customer_third_hop_id__third_hop_ds__extract_day + , subq_0.customer_third_hop_id__third_hop_ds__extract_dow + , subq_0.customer_third_hop_id__third_hop_ds__extract_doy + , subq_0.third_hop_ds__day AS metric_time__day + , subq_0.third_hop_ds__week AS metric_time__week + , subq_0.third_hop_ds__month AS metric_time__month + , subq_0.third_hop_ds__quarter AS metric_time__quarter + , subq_0.third_hop_ds__year AS metric_time__year + , subq_0.third_hop_ds__extract_year AS metric_time__extract_year + , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter + , subq_0.third_hop_ds__extract_month AS metric_time__extract_month + , subq_0.third_hop_ds__extract_day AS metric_time__extract_day + , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow + , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy + , subq_0.customer_third_hop_id + , subq_0.value + , subq_0.customer_third_hop_id__value + , subq_0.third_hop_count FROM ( - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id'] + -- Read Elements From Semantic Model 'third_hop_table' SELECT - subq_1.customer_third_hop_id - , subq_1.third_hop_count - FROM ( - -- Metric Time Dimension 'third_hop_ds' - SELECT - subq_0.third_hop_ds__day - , subq_0.third_hop_ds__week - , subq_0.third_hop_ds__month - , subq_0.third_hop_ds__quarter - , subq_0.third_hop_ds__year - , subq_0.third_hop_ds__extract_year - , subq_0.third_hop_ds__extract_quarter - , subq_0.third_hop_ds__extract_month - , subq_0.third_hop_ds__extract_day - , subq_0.third_hop_ds__extract_dow - , subq_0.third_hop_ds__extract_doy - , subq_0.customer_third_hop_id__third_hop_ds__day - , subq_0.customer_third_hop_id__third_hop_ds__week - , subq_0.customer_third_hop_id__third_hop_ds__month - , subq_0.customer_third_hop_id__third_hop_ds__quarter - , subq_0.customer_third_hop_id__third_hop_ds__year - , subq_0.customer_third_hop_id__third_hop_ds__extract_year - , subq_0.customer_third_hop_id__third_hop_ds__extract_quarter - , subq_0.customer_third_hop_id__third_hop_ds__extract_month - , subq_0.customer_third_hop_id__third_hop_ds__extract_day - , subq_0.customer_third_hop_id__third_hop_ds__extract_dow - , subq_0.customer_third_hop_id__third_hop_ds__extract_doy - , subq_0.third_hop_ds__day AS metric_time__day - , subq_0.third_hop_ds__week AS metric_time__week - , subq_0.third_hop_ds__month AS metric_time__month - , subq_0.third_hop_ds__quarter AS metric_time__quarter - , subq_0.third_hop_ds__year AS metric_time__year - , subq_0.third_hop_ds__extract_year AS metric_time__extract_year - , subq_0.third_hop_ds__extract_quarter AS metric_time__extract_quarter - , subq_0.third_hop_ds__extract_month AS metric_time__extract_month - , subq_0.third_hop_ds__extract_day AS metric_time__extract_day - , subq_0.third_hop_ds__extract_dow AS metric_time__extract_dow - , subq_0.third_hop_ds__extract_doy AS metric_time__extract_doy - , subq_0.customer_third_hop_id - , subq_0.value - , subq_0.customer_third_hop_id__value - , subq_0.third_hop_count - FROM ( - -- Read Elements From Semantic Model 'third_hop_table' - SELECT - third_hop_table_src_22000.customer_third_hop_id AS third_hop_count - , third_hop_table_src_22000.value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy - , third_hop_table_src_22000.value AS customer_third_hop_id__value - , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day - , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week - , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month - , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter - , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year - , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year - , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter - , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month - , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow - , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy - , third_hop_table_src_22000.customer_third_hop_id - FROM ***************************.third_hop_table third_hop_table_src_22000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + third_hop_table_src_22000.customer_third_hop_id AS third_hop_count + , third_hop_table_src_22000.value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS third_hop_ds__extract_doy + , third_hop_table_src_22000.value AS customer_third_hop_id__value + , DATE_TRUNC('day', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__day + , DATE_TRUNC('week', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__week + , DATE_TRUNC('month', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__month + , DATE_TRUNC('quarter', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__quarter + , DATE_TRUNC('year', third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__year + , EXTRACT(year FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_year + , EXTRACT(quarter FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_quarter + , EXTRACT(month FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_month + , EXTRACT(day FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_dow + , EXTRACT(doy FROM third_hop_table_src_22000.third_hop_ds) AS customer_third_hop_id__third_hop_ds__extract_doy + , third_hop_table_src_22000.customer_third_hop_id + FROM ***************************.third_hop_table third_hop_table_src_22000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['customer_id__customer_third_hop_id', 'customer_id__customer_third_hop_id__paraguayan_customers'] + SELECT + subq_7.customer_id__customer_third_hop_id + , subq_7.customer_id__customer_third_hop_id__paraguayan_customers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_9.customer_id__customer_third_hop_id - , subq_9.customer_id__customer_third_hop_id__paraguayan_customers + subq_6.customer_id__customer_third_hop_id + , subq_6.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_8.customer_id__customer_third_hop_id - , subq_8.customers_with_other_data AS customer_id__customer_third_hop_id__paraguayan_customers + subq_5.customer_id__customer_third_hop_id + , SUM(subq_5.customers_with_other_data) AS customers_with_other_data FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] SELECT - subq_7.customer_id__customer_third_hop_id - , SUM(subq_7.customers_with_other_data) AS customers_with_other_data + subq_4.customer_id__customer_third_hop_id + , subq_4.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__customer_third_hop_id'] + -- Constrain Output with WHERE SELECT - subq_6.customer_id__customer_third_hop_id - , subq_6.customers_with_other_data + subq_3.acquired_ds__day + , subq_3.acquired_ds__week + , subq_3.acquired_ds__month + , subq_3.acquired_ds__quarter + , subq_3.acquired_ds__year + , subq_3.acquired_ds__extract_year + , subq_3.acquired_ds__extract_quarter + , subq_3.acquired_ds__extract_month + , subq_3.acquired_ds__extract_day + , subq_3.acquired_ds__extract_dow + , subq_3.acquired_ds__extract_doy + , subq_3.customer_id__acquired_ds__day + , subq_3.customer_id__acquired_ds__week + , subq_3.customer_id__acquired_ds__month + , subq_3.customer_id__acquired_ds__quarter + , subq_3.customer_id__acquired_ds__year + , subq_3.customer_id__acquired_ds__extract_year + , subq_3.customer_id__acquired_ds__extract_quarter + , subq_3.customer_id__acquired_ds__extract_month + , subq_3.customer_id__acquired_ds__extract_day + , subq_3.customer_id__acquired_ds__extract_dow + , subq_3.customer_id__acquired_ds__extract_doy + , subq_3.customer_third_hop_id__acquired_ds__day + , subq_3.customer_third_hop_id__acquired_ds__week + , subq_3.customer_third_hop_id__acquired_ds__month + , subq_3.customer_third_hop_id__acquired_ds__quarter + , subq_3.customer_third_hop_id__acquired_ds__year + , subq_3.customer_third_hop_id__acquired_ds__extract_year + , subq_3.customer_third_hop_id__acquired_ds__extract_quarter + , subq_3.customer_third_hop_id__acquired_ds__extract_month + , subq_3.customer_third_hop_id__acquired_ds__extract_day + , subq_3.customer_third_hop_id__acquired_ds__extract_dow + , subq_3.customer_third_hop_id__acquired_ds__extract_doy + , subq_3.metric_time__day + , subq_3.metric_time__week + , subq_3.metric_time__month + , subq_3.metric_time__quarter + , subq_3.metric_time__year + , subq_3.metric_time__extract_year + , subq_3.metric_time__extract_quarter + , subq_3.metric_time__extract_month + , subq_3.metric_time__extract_day + , subq_3.metric_time__extract_dow + , subq_3.metric_time__extract_doy + , subq_3.customer_id + , subq_3.customer_third_hop_id + , subq_3.customer_id__customer_third_hop_id + , subq_3.customer_third_hop_id__customer_id + , subq_3.country + , subq_3.customer_id__country + , subq_3.customer_third_hop_id__country + , subq_3.customers_with_other_data FROM ( - -- Constrain Output with WHERE + -- Metric Time Dimension 'acquired_ds' SELECT - subq_5.customer_id__customer_third_hop_id - , subq_5.customer_id__country - , subq_5.customers_with_other_data + subq_2.acquired_ds__day + , subq_2.acquired_ds__week + , subq_2.acquired_ds__month + , subq_2.acquired_ds__quarter + , subq_2.acquired_ds__year + , subq_2.acquired_ds__extract_year + , subq_2.acquired_ds__extract_quarter + , subq_2.acquired_ds__extract_month + , subq_2.acquired_ds__extract_day + , subq_2.acquired_ds__extract_dow + , subq_2.acquired_ds__extract_doy + , subq_2.customer_id__acquired_ds__day + , subq_2.customer_id__acquired_ds__week + , subq_2.customer_id__acquired_ds__month + , subq_2.customer_id__acquired_ds__quarter + , subq_2.customer_id__acquired_ds__year + , subq_2.customer_id__acquired_ds__extract_year + , subq_2.customer_id__acquired_ds__extract_quarter + , subq_2.customer_id__acquired_ds__extract_month + , subq_2.customer_id__acquired_ds__extract_day + , subq_2.customer_id__acquired_ds__extract_dow + , subq_2.customer_id__acquired_ds__extract_doy + , subq_2.customer_third_hop_id__acquired_ds__day + , subq_2.customer_third_hop_id__acquired_ds__week + , subq_2.customer_third_hop_id__acquired_ds__month + , subq_2.customer_third_hop_id__acquired_ds__quarter + , subq_2.customer_third_hop_id__acquired_ds__year + , subq_2.customer_third_hop_id__acquired_ds__extract_year + , subq_2.customer_third_hop_id__acquired_ds__extract_quarter + , subq_2.customer_third_hop_id__acquired_ds__extract_month + , subq_2.customer_third_hop_id__acquired_ds__extract_day + , subq_2.customer_third_hop_id__acquired_ds__extract_dow + , subq_2.customer_third_hop_id__acquired_ds__extract_doy + , subq_2.acquired_ds__day AS metric_time__day + , subq_2.acquired_ds__week AS metric_time__week + , subq_2.acquired_ds__month AS metric_time__month + , subq_2.acquired_ds__quarter AS metric_time__quarter + , subq_2.acquired_ds__year AS metric_time__year + , subq_2.acquired_ds__extract_year AS metric_time__extract_year + , subq_2.acquired_ds__extract_quarter AS metric_time__extract_quarter + , subq_2.acquired_ds__extract_month AS metric_time__extract_month + , subq_2.acquired_ds__extract_day AS metric_time__extract_day + , subq_2.acquired_ds__extract_dow AS metric_time__extract_dow + , subq_2.acquired_ds__extract_doy AS metric_time__extract_doy + , subq_2.customer_id + , subq_2.customer_third_hop_id + , subq_2.customer_id__customer_third_hop_id + , subq_2.customer_third_hop_id__customer_id + , subq_2.country + , subq_2.customer_id__country + , subq_2.customer_third_hop_id__country + , subq_2.customers_with_other_data FROM ( - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] + -- Read Elements From Semantic Model 'customer_other_data' SELECT - subq_4.customer_id__customer_third_hop_id - , subq_4.customer_id__country - , subq_4.customers_with_other_data - FROM ( - -- Metric Time Dimension 'acquired_ds' - SELECT - subq_3.acquired_ds__day - , subq_3.acquired_ds__week - , subq_3.acquired_ds__month - , subq_3.acquired_ds__quarter - , subq_3.acquired_ds__year - , subq_3.acquired_ds__extract_year - , subq_3.acquired_ds__extract_quarter - , subq_3.acquired_ds__extract_month - , subq_3.acquired_ds__extract_day - , subq_3.acquired_ds__extract_dow - , subq_3.acquired_ds__extract_doy - , subq_3.customer_id__acquired_ds__day - , subq_3.customer_id__acquired_ds__week - , subq_3.customer_id__acquired_ds__month - , subq_3.customer_id__acquired_ds__quarter - , subq_3.customer_id__acquired_ds__year - , subq_3.customer_id__acquired_ds__extract_year - , subq_3.customer_id__acquired_ds__extract_quarter - , subq_3.customer_id__acquired_ds__extract_month - , subq_3.customer_id__acquired_ds__extract_day - , subq_3.customer_id__acquired_ds__extract_dow - , subq_3.customer_id__acquired_ds__extract_doy - , subq_3.customer_third_hop_id__acquired_ds__day - , subq_3.customer_third_hop_id__acquired_ds__week - , subq_3.customer_third_hop_id__acquired_ds__month - , subq_3.customer_third_hop_id__acquired_ds__quarter - , subq_3.customer_third_hop_id__acquired_ds__year - , subq_3.customer_third_hop_id__acquired_ds__extract_year - , subq_3.customer_third_hop_id__acquired_ds__extract_quarter - , subq_3.customer_third_hop_id__acquired_ds__extract_month - , subq_3.customer_third_hop_id__acquired_ds__extract_day - , subq_3.customer_third_hop_id__acquired_ds__extract_dow - , subq_3.customer_third_hop_id__acquired_ds__extract_doy - , subq_3.acquired_ds__day AS metric_time__day - , subq_3.acquired_ds__week AS metric_time__week - , subq_3.acquired_ds__month AS metric_time__month - , subq_3.acquired_ds__quarter AS metric_time__quarter - , subq_3.acquired_ds__year AS metric_time__year - , subq_3.acquired_ds__extract_year AS metric_time__extract_year - , subq_3.acquired_ds__extract_quarter AS metric_time__extract_quarter - , subq_3.acquired_ds__extract_month AS metric_time__extract_month - , subq_3.acquired_ds__extract_day AS metric_time__extract_day - , subq_3.acquired_ds__extract_dow AS metric_time__extract_dow - , subq_3.acquired_ds__extract_doy AS metric_time__extract_doy - , subq_3.customer_id - , subq_3.customer_third_hop_id - , subq_3.customer_id__customer_third_hop_id - , subq_3.customer_third_hop_id__customer_id - , subq_3.country - , subq_3.customer_id__country - , subq_3.customer_third_hop_id__country - , subq_3.customers_with_other_data - FROM ( - -- Read Elements From Semantic Model 'customer_other_data' - SELECT - 1 AS customers_with_other_data - , customer_other_data_src_22000.country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy - , customer_other_data_src_22000.country AS customer_third_hop_id__country - , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day - , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week - , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month - , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter - , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year - , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year - , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter - , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month - , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow - , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy - , customer_other_data_src_22000.customer_id - , customer_other_data_src_22000.customer_third_hop_id - , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id - , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id - FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_3 - ) subq_4 - ) subq_5 - WHERE customer_id__country = 'paraguay' - ) subq_6 - ) subq_7 - GROUP BY - subq_7.customer_id__customer_third_hop_id - ) subq_8 - ) subq_9 - ) subq_10 - ON - subq_2.customer_third_hop_id = subq_10.customer_id__customer_third_hop_id - ) subq_11 - ) subq_12 + 1 AS customers_with_other_data + , customer_other_data_src_22000.country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_id__acquired_ds__extract_doy + , customer_other_data_src_22000.country AS customer_third_hop_id__country + , DATE_TRUNC('day', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__day + , DATE_TRUNC('week', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__week + , DATE_TRUNC('month', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__month + , DATE_TRUNC('quarter', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__quarter + , DATE_TRUNC('year', customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__year + , EXTRACT(year FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_year + , EXTRACT(quarter FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_quarter + , EXTRACT(month FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_month + , EXTRACT(day FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_dow + , EXTRACT(doy FROM customer_other_data_src_22000.acquired_ds) AS customer_third_hop_id__acquired_ds__extract_doy + , customer_other_data_src_22000.customer_id + , customer_other_data_src_22000.customer_third_hop_id + , customer_other_data_src_22000.customer_third_hop_id AS customer_id__customer_third_hop_id + , customer_other_data_src_22000.customer_id AS customer_third_hop_id__customer_id + FROM ***************************.customer_other_data customer_other_data_src_22000 + ) subq_2 + ) subq_3 + WHERE customer_id__country = 'paraguay' + ) subq_4 + ) subq_5 + GROUP BY + subq_5.customer_id__customer_third_hop_id + ) subq_6 + ) subq_7 + ) subq_8 + ON + subq_1.customer_third_hop_id = subq_8.customer_id__customer_third_hop_id + ) subq_9 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 - ) subq_13 - ) subq_14 -) subq_15 + ) subq_10 + ) subq_11 +) subq_12 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql index 803f2dc0b1..d1a69b0cca 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_inner_query_single_hop__plan0_optimized.sql @@ -6,9 +6,8 @@ SELECT COUNT(DISTINCT third_hop_count) AS third_hop_count FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['third_hop_count', 'customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers'] SELECT - subq_26.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers + subq_21.customer_id__customer_third_hop_id__paraguayan_customers AS customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers , third_hop_table_src_22000.customer_third_hop_id AS third_hop_count FROM ***************************.third_hop_table third_hop_table_src_22000 LEFT OUTER JOIN ( @@ -23,18 +22,17 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'customer_other_data' -- Metric Time Dimension 'acquired_ds' - -- Pass Only Elements: ['customers_with_other_data', 'customer_id__country', 'customer_id__customer_third_hop_id'] SELECT customer_third_hop_id AS customer_id__customer_third_hop_id , country AS customer_id__country , 1 AS customers_with_other_data FROM ***************************.customer_other_data customer_other_data_src_22000 - ) subq_21 + ) subq_16 WHERE customer_id__country = 'paraguay' GROUP BY customer_id__customer_third_hop_id - ) subq_26 + ) subq_21 ON - third_hop_table_src_22000.customer_third_hop_id = subq_26.customer_id__customer_third_hop_id -) subq_28 + third_hop_table_src_22000.customer_third_hop_id = subq_21.customer_id__customer_third_hop_id +) subq_22 WHERE customer_third_hop_id__customer_id__customer_third_hop_id__paraguayan_customers > 0 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql index 8a5e43d716..759719ae56 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0.sql @@ -1,457 +1,638 @@ -- Compute Metrics via Expressions SELECT - subq_13.bookers + subq_11.bookers FROM ( -- Aggregate Measures SELECT - COUNT(DISTINCT subq_12.bookers) AS bookers + COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers',] SELECT - subq_11.bookers + subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookers - , subq_10.bookers + 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.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.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.listing__bookers + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_9.listing__bookers - , subq_9.bookers + subq_7.listing__bookers AS listing__bookers + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.bookers AS bookers + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.bookers - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_6.listing + , subq_6.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookers + subq_5.listing + , subq_5.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookers AS listing__bookers + subq_4.listing + , COUNT(DISTINCT subq_4.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_5.listing - , COUNT(DISTINCT subq_5.bookers) AS bookers + subq_3.listing + , subq_3.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookers + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookers > 1.00 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql index fc6f75f09e..2670479341 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_filtered_by_itself__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT COUNT(DISTINCT bookers) AS bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__bookers'] SELECT - subq_22.listing__bookers AS listing__bookers - , subq_16.bookers AS bookers + subq_19.listing__bookers AS listing__bookers + , subq_13.bookers AS bookers FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookers', 'listing'] SELECT listing_id AS listing , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookers > 1.00 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql index d559ec3bc4..0eb9df5f6d 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0.sql @@ -1,403 +1,518 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listings AS active_listings + subq_11.metric_time__day + , subq_11.listings AS active_listings FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , SUM(subq_12.listings) AS listings + subq_10.metric_time__day + , SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listings + subq_9.metric_time__day + , subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day -) subq_13 + subq_10.metric_time__day +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql index 21fd1f7db3..6099c2233b 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_metric_with_metric_in_where_filter__plan0_optimized.sql @@ -7,21 +7,19 @@ SELECT , SUM(listings) AS active_listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing__bookings'] SELECT - subq_16.metric_time__day AS metric_time__day - , subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.metric_time__day AS metric_time__day + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -37,13 +35,13 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql index 3a2c363bc9..a02a059e59 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0.sql @@ -1,269 +1,388 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.user__revenue_all_time - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.user__revenue_all_time + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] + -- Join Standard Outputs SELECT - subq_9.user__revenue_all_time - , subq_9.listings + subq_7.user__revenue_all_time AS user__revenue_all_time + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.user__revenue_all_time AS user__revenue_all_time - , subq_2.user AS user - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['user', 'user__revenue_all_time'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['user', 'user__revenue_all_time'] + SELECT + subq_6.user + , subq_6.user__revenue_all_time + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.user - , subq_7.user__revenue_all_time + subq_5.user + , subq_5.txn_revenue AS user__revenue_all_time FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.user - , subq_6.txn_revenue AS user__revenue_all_time + subq_4.user + , SUM(subq_4.txn_revenue) AS txn_revenue FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['txn_revenue', 'user'] SELECT - subq_5.user - , SUM(subq_5.txn_revenue) AS txn_revenue + subq_3.user + , subq_3.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_4.user - , subq_4.txn_revenue + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.revenue_instance__ds__day + , subq_2.revenue_instance__ds__week + , subq_2.revenue_instance__ds__month + , subq_2.revenue_instance__ds__quarter + , subq_2.revenue_instance__ds__year + , subq_2.revenue_instance__ds__extract_year + , subq_2.revenue_instance__ds__extract_quarter + , subq_2.revenue_instance__ds__extract_month + , subq_2.revenue_instance__ds__extract_day + , subq_2.revenue_instance__ds__extract_dow + , subq_2.revenue_instance__ds__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.revenue_instance__user + , subq_2.txn_revenue FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'revenue' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.revenue_instance__ds__day - , subq_3.revenue_instance__ds__week - , subq_3.revenue_instance__ds__month - , subq_3.revenue_instance__ds__quarter - , subq_3.revenue_instance__ds__year - , subq_3.revenue_instance__ds__extract_year - , subq_3.revenue_instance__ds__extract_quarter - , subq_3.revenue_instance__ds__extract_month - , subq_3.revenue_instance__ds__extract_day - , subq_3.revenue_instance__ds__extract_dow - , subq_3.revenue_instance__ds__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.revenue_instance__user - , subq_3.txn_revenue - FROM ( - -- Read Elements From Semantic Model 'revenue' - SELECT - 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_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.user - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.user = subq_8.user - ) subq_9 - ) subq_10 + 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_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.user + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.user = subq_7.user + ) subq_8 WHERE user__revenue_all_time > 1 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql index 2b782589e8..aedda5822a 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_cumulative_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__revenue_all_time'] SELECT - subq_22.user__revenue_all_time AS user__revenue_all_time - , subq_16.listings AS listings + subq_19.user__revenue_all_time AS user__revenue_all_time + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'user'] SELECT user_id AS user , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' @@ -32,8 +30,8 @@ FROM ( FROM ***************************.fct_revenue revenue_src_28000 GROUP BY user_id - ) subq_22 + ) subq_19 ON - subq_16.user = subq_22.user -) subq_24 + subq_13.user = subq_19.user +) subq_20 WHERE user__revenue_all_time > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql index 1904d4dfc7..8f86a49362 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0.sql @@ -1,549 +1,668 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__views_times_booking_value - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__views_times_booking_value + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] + -- Join Standard Outputs SELECT - subq_16.listing__views_times_booking_value - , subq_16.listings + subq_14.listing__views_times_booking_value AS listing__views_times_booking_value + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] + SELECT + subq_13.listing + , subq_13.listing__views_times_booking_value + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__views_times_booking_value + subq_12.listing + , booking_value * views AS listing__views_times_booking_value FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , booking_value * views AS listing__views_times_booking_value + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.booking_value) AS booking_value + , MAX(subq_11.views) AS views FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.booking_value) AS booking_value - , MAX(subq_12.views) AS views + subq_5.listing + , subq_5.booking_value FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.booking_value + subq_4.listing + , SUM(subq_4.booking_value) AS booking_value FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['booking_value', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.booking_value) AS booking_value + subq_3.listing + , subq_3.booking_value FROM ( - -- Pass Only Elements: ['booking_value', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.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.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.views + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.views + subq_9.listing + , SUM(subq_9.views) AS views FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['views', 'listing'] SELECT - subq_10.listing - , SUM(subq_10.views) AS views + subq_8.listing + , subq_8.views FROM ( - -- Pass Only Elements: ['views', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.views + 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.view__ds__day + , subq_7.view__ds__week + , subq_7.view__ds__month + , subq_7.view__ds__quarter + , subq_7.view__ds__year + , subq_7.view__ds__extract_year + , subq_7.view__ds__extract_quarter + , subq_7.view__ds__extract_month + , subq_7.view__ds__extract_day + , subq_7.view__ds__extract_dow + , subq_7.view__ds__extract_doy + , subq_7.view__ds_partitioned__day + , subq_7.view__ds_partitioned__week + , subq_7.view__ds_partitioned__month + , subq_7.view__ds_partitioned__quarter + , subq_7.view__ds_partitioned__year + , subq_7.view__ds_partitioned__extract_year + , subq_7.view__ds_partitioned__extract_quarter + , subq_7.view__ds_partitioned__extract_month + , subq_7.view__ds_partitioned__extract_day + , subq_7.view__ds_partitioned__extract_dow + , subq_7.view__ds_partitioned__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.user + , subq_7.view__listing + , subq_7.view__user + , subq_7.views FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'views_source' 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.view__ds__day - , subq_8.view__ds__week - , subq_8.view__ds__month - , subq_8.view__ds__quarter - , subq_8.view__ds__year - , subq_8.view__ds__extract_year - , subq_8.view__ds__extract_quarter - , subq_8.view__ds__extract_month - , subq_8.view__ds__extract_day - , subq_8.view__ds__extract_dow - , subq_8.view__ds__extract_doy - , subq_8.view__ds_partitioned__day - , subq_8.view__ds_partitioned__week - , subq_8.view__ds_partitioned__month - , subq_8.view__ds_partitioned__quarter - , subq_8.view__ds_partitioned__year - , subq_8.view__ds_partitioned__extract_year - , subq_8.view__ds_partitioned__extract_quarter - , subq_8.view__ds_partitioned__extract_month - , subq_8.view__ds_partitioned__extract_day - , subq_8.view__ds_partitioned__extract_dow - , subq_8.view__ds_partitioned__extract_doy - , subq_8.ds__day AS metric_time__day - , subq_8.ds__week AS metric_time__week - , subq_8.ds__month AS metric_time__month - , subq_8.ds__quarter AS metric_time__quarter - , subq_8.ds__year AS metric_time__year - , subq_8.ds__extract_year AS metric_time__extract_year - , subq_8.ds__extract_quarter AS metric_time__extract_quarter - , subq_8.ds__extract_month AS metric_time__extract_month - , subq_8.ds__extract_day AS metric_time__extract_day - , subq_8.ds__extract_dow AS metric_time__extract_dow - , subq_8.ds__extract_doy AS metric_time__extract_doy - , subq_8.listing - , subq_8.user - , subq_8.view__listing - , subq_8.view__user - , subq_8.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS views + , 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_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__views_times_booking_value > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql index e5f6bf61fb..7bb1c0f3a7 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_derived_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__views_times_booking_value'] SELECT - subq_36.listing__views_times_booking_value AS listing__views_times_booking_value - , subq_23.listings AS listings + subq_33.listing__views_times_booking_value AS listing__views_times_booking_value + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Compute Metrics via Expressions -- Pass Only Elements: ['listing', 'listing__views_times_booking_value'] @@ -28,9 +26,9 @@ FROM ( FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_28.listing, subq_33.listing) AS listing - , MAX(subq_28.booking_value) AS booking_value - , MAX(subq_33.views) AS views + COALESCE(subq_25.listing, subq_30.listing) AS listing + , MAX(subq_25.booking_value) AS booking_value + , MAX(subq_30.views) AS views FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -43,7 +41,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_28 + ) subq_25 FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -58,17 +56,17 @@ FROM ( listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_31 + ) subq_28 GROUP BY listing - ) subq_33 + ) subq_30 ON - subq_28.listing = subq_33.listing + subq_25.listing = subq_30.listing GROUP BY - COALESCE(subq_28.listing, subq_33.listing) - ) subq_34 - ) subq_36 + COALESCE(subq_25.listing, subq_30.listing) + ) subq_31 + ) subq_33 ON - subq_23.listing = subq_36.listing -) subq_38 + subq_20.listing = subq_33.listing +) subq_34 WHERE listing__views_times_booking_value > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql index 7781a7d54c..2b64cfd11e 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0.sql @@ -1,620 +1,738 @@ -- Compute Metrics via Expressions SELECT - subq_19.listings + subq_17.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_18.listings) AS listings + SUM(subq_16.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_17.listings + subq_15.listings FROM ( -- Constrain Output with WHERE SELECT - subq_16.listing__bookings - , subq_16.listing__bookers - , subq_16.listings + 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.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.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.listing__bookings + , subq_14.listing__bookers + , subq_14.listings + , subq_14.largest_listing + , subq_14.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] + -- Join Standard Outputs SELECT - subq_15.listing__bookings - , subq_15.listing__bookers - , subq_15.listings + subq_7.listing__bookings AS listing__bookings + , subq_13.listing__bookers AS listing__bookers + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_14.listing__bookers AS listing__bookers - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookers'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookers'] + SELECT + subq_12.listing + , subq_12.listing__bookers + FROM ( + -- Compute Metrics via Expressions SELECT - subq_13.listing - , subq_13.listing__bookers + subq_11.listing + , subq_11.bookers AS listing__bookers FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_12.listing - , subq_12.bookers AS listing__bookers + subq_10.listing + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_11.listing - , COUNT(DISTINCT subq_11.bookers) AS bookers + subq_9.listing + , subq_9.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_10.listing - , subq_10.bookers + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.ds_partitioned__day + , subq_8.ds_partitioned__week + , subq_8.ds_partitioned__month + , subq_8.ds_partitioned__quarter + , subq_8.ds_partitioned__year + , subq_8.ds_partitioned__extract_year + , subq_8.ds_partitioned__extract_quarter + , subq_8.ds_partitioned__extract_month + , subq_8.ds_partitioned__extract_day + , subq_8.ds_partitioned__extract_dow + , subq_8.ds_partitioned__extract_doy + , subq_8.paid_at__day + , subq_8.paid_at__week + , subq_8.paid_at__month + , subq_8.paid_at__quarter + , subq_8.paid_at__year + , subq_8.paid_at__extract_year + , subq_8.paid_at__extract_quarter + , subq_8.paid_at__extract_month + , subq_8.paid_at__extract_day + , subq_8.paid_at__extract_dow + , subq_8.paid_at__extract_doy + , subq_8.booking__ds__day + , subq_8.booking__ds__week + , subq_8.booking__ds__month + , subq_8.booking__ds__quarter + , subq_8.booking__ds__year + , subq_8.booking__ds__extract_year + , subq_8.booking__ds__extract_quarter + , subq_8.booking__ds__extract_month + , subq_8.booking__ds__extract_day + , subq_8.booking__ds__extract_dow + , subq_8.booking__ds__extract_doy + , subq_8.booking__ds_partitioned__day + , subq_8.booking__ds_partitioned__week + , subq_8.booking__ds_partitioned__month + , subq_8.booking__ds_partitioned__quarter + , subq_8.booking__ds_partitioned__year + , subq_8.booking__ds_partitioned__extract_year + , subq_8.booking__ds_partitioned__extract_quarter + , subq_8.booking__ds_partitioned__extract_month + , subq_8.booking__ds_partitioned__extract_day + , subq_8.booking__ds_partitioned__extract_dow + , subq_8.booking__ds_partitioned__extract_doy + , subq_8.booking__paid_at__day + , subq_8.booking__paid_at__week + , subq_8.booking__paid_at__month + , subq_8.booking__paid_at__quarter + , subq_8.booking__paid_at__year + , subq_8.booking__paid_at__extract_year + , subq_8.booking__paid_at__extract_quarter + , subq_8.booking__paid_at__extract_month + , subq_8.booking__paid_at__extract_day + , subq_8.booking__paid_at__extract_dow + , subq_8.booking__paid_at__extract_doy + , subq_8.ds__day AS metric_time__day + , subq_8.ds__week AS metric_time__week + , subq_8.ds__month AS metric_time__month + , subq_8.ds__quarter AS metric_time__quarter + , subq_8.ds__year AS metric_time__year + , subq_8.ds__extract_year AS metric_time__extract_year + , subq_8.ds__extract_quarter AS metric_time__extract_quarter + , subq_8.ds__extract_month AS metric_time__extract_month + , subq_8.ds__extract_day AS metric_time__extract_day + , subq_8.ds__extract_dow AS metric_time__extract_dow + , subq_8.ds__extract_doy AS metric_time__extract_doy + , subq_8.listing + , subq_8.guest + , subq_8.host + , subq_8.booking__listing + , subq_8.booking__guest + , subq_8.booking__host + , subq_8.is_instant + , subq_8.booking__is_instant + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 - ) subq_10 - ) subq_11 - GROUP BY - subq_11.listing - ) subq_12 - ) subq_13 - ) subq_14 - ON - subq_2.listing = subq_14.listing - ) subq_15 - ) subq_16 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_8 + ) subq_9 + ) subq_10 + GROUP BY + subq_10.listing + ) subq_11 + ) subq_12 + ) subq_13 + ON + subq_1.listing = subq_13.listing + ) subq_14 WHERE listing__bookings > 2 AND listing__bookers > 1 - ) subq_17 - ) subq_18 -) subq_19 + ) subq_15 + ) subq_16 +) subq_17 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql index 767f0b3fea..0a8508c1ae 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_multiple_metrics_in_filter__plan0_optimized.sql @@ -6,20 +6,18 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings', 'listing__bookers'] SELECT - subq_28.listing__bookings AS listing__bookings - , subq_34.listing__bookers AS listing__bookers - , subq_22.listings AS listings + subq_25.listing__bookings AS listing__bookings + , subq_31.listing__bookers AS listing__bookers + , subq_19.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_22 + ) subq_19 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,12 +33,12 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_25 + ) subq_22 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_22.listing = subq_28.listing + subq_19.listing = subq_25.listing LEFT OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -54,8 +52,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY listing_id - ) subq_34 + ) subq_31 ON - subq_22.listing = subq_34.listing -) subq_36 + subq_19.listing = subq_31.listing +) subq_32 WHERE listing__bookings > 2 AND listing__bookers > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql index 40bb3f4b49..d6035679dd 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0.sql @@ -1,626 +1,745 @@ -- Compute Metrics via Expressions SELECT - subq_20.listings + subq_18.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_19.listings) AS listings + SUM(subq_17.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_18.listings + subq_16.listings FROM ( -- Constrain Output with WHERE SELECT - subq_17.listing__bookings_per_booker - , subq_17.listings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__bookings_per_booker + , subq_15.listings + , subq_15.largest_listing + , subq_15.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] + -- Join Standard Outputs SELECT - subq_16.listing__bookings_per_booker - , subq_16.listings + subq_14.listing__bookings_per_booker AS listing__bookings_per_booker + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_15.listing__bookings_per_booker AS listing__bookings_per_booker - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings_per_booker'] + SELECT + subq_13.listing + , subq_13.listing__bookings_per_booker + FROM ( + -- Compute Metrics via Expressions SELECT - subq_14.listing - , subq_14.listing__bookings_per_booker + subq_12.listing + , CAST(subq_12.bookings AS DOUBLE) / CAST(NULLIF(subq_12.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker FROM ( - -- Compute Metrics via Expressions + -- Combine Aggregated Outputs SELECT - subq_13.listing - , CAST(subq_13.bookings AS DOUBLE) / CAST(NULLIF(subq_13.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + COALESCE(subq_6.listing, subq_11.listing) AS listing + , MAX(subq_6.bookings) AS bookings + , MAX(subq_11.bookers) AS bookers FROM ( - -- Combine Aggregated Outputs + -- Compute Metrics via Expressions SELECT - COALESCE(subq_7.listing, subq_12.listing) AS listing - , MAX(subq_7.bookings) AS bookings - , MAX(subq_12.bookers) AS bookers + subq_5.listing + , subq_5.bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_10.listing + , subq_10.bookers + FROM ( + -- Aggregate Measures SELECT - subq_11.listing - , subq_11.bookers + subq_9.listing + , COUNT(DISTINCT subq_9.bookers) AS bookers FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookers', 'listing'] SELECT - subq_10.listing - , COUNT(DISTINCT subq_10.bookers) AS bookers + subq_8.listing + , subq_8.bookers FROM ( - -- Pass Only Elements: ['bookers', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_9.listing - , subq_9.bookers + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_8 - ) subq_9 - ) subq_10 - GROUP BY - subq_10.listing - ) subq_11 - ) subq_12 - ON - subq_7.listing = subq_12.listing - GROUP BY - COALESCE(subq_7.listing, subq_12.listing) - ) subq_13 - ) subq_14 - ) subq_15 - ON - subq_2.listing = subq_15.listing - ) subq_16 - ) subq_17 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_7 + ) subq_8 + ) subq_9 + GROUP BY + subq_9.listing + ) subq_10 + ) subq_11 + ON + subq_6.listing = subq_11.listing + GROUP BY + COALESCE(subq_6.listing, subq_11.listing) + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_1.listing = subq_14.listing + ) subq_15 WHERE listing__bookings_per_booker > 1 - ) subq_18 - ) subq_19 -) subq_20 + ) subq_16 + ) subq_17 +) subq_18 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql index 4847f003cd..c013b4d97f 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_ratio_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings_per_booker'] SELECT - CAST(subq_28.bookings AS DOUBLE) / CAST(NULLIF(subq_28.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker - , subq_23.listings AS listings + CAST(subq_25.bookings AS DOUBLE) / CAST(NULLIF(subq_25.bookers, 0) AS DOUBLE) AS listing__bookings_per_booker + , subq_20.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_23 + ) subq_20 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -35,11 +33,11 @@ FROM ( , 1 AS bookings , guest_id AS bookers FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_26 + ) subq_23 GROUP BY listing - ) subq_28 + ) subq_25 ON - subq_23.listing = subq_28.listing -) subq_32 + subq_20.listing = subq_25.listing +) subq_28 WHERE listing__bookings_per_booker > 1 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql index 56c887c51b..d406e48ffd 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0.sql @@ -1,394 +1,513 @@ -- Compute Metrics via Expressions SELECT - subq_13.listings + subq_11.listings FROM ( -- Aggregate Measures SELECT - SUM(subq_12.listings) AS listings + SUM(subq_10.listings) AS listings FROM ( -- Pass Only Elements: ['listings',] SELECT - subq_11.listings + subq_9.listings FROM ( -- Constrain Output with WHERE SELECT - subq_10.listing__bookings - , subq_10.listings + subq_8.ds__day + , subq_8.ds__week + , subq_8.ds__month + , subq_8.ds__quarter + , subq_8.ds__year + , subq_8.ds__extract_year + , subq_8.ds__extract_quarter + , subq_8.ds__extract_month + , subq_8.ds__extract_day + , subq_8.ds__extract_dow + , subq_8.ds__extract_doy + , subq_8.created_at__day + , subq_8.created_at__week + , subq_8.created_at__month + , subq_8.created_at__quarter + , subq_8.created_at__year + , subq_8.created_at__extract_year + , subq_8.created_at__extract_quarter + , subq_8.created_at__extract_month + , subq_8.created_at__extract_day + , subq_8.created_at__extract_dow + , subq_8.created_at__extract_doy + , subq_8.listing__ds__day + , subq_8.listing__ds__week + , subq_8.listing__ds__month + , subq_8.listing__ds__quarter + , subq_8.listing__ds__year + , subq_8.listing__ds__extract_year + , subq_8.listing__ds__extract_quarter + , subq_8.listing__ds__extract_month + , subq_8.listing__ds__extract_day + , subq_8.listing__ds__extract_dow + , subq_8.listing__ds__extract_doy + , subq_8.listing__created_at__day + , subq_8.listing__created_at__week + , subq_8.listing__created_at__month + , subq_8.listing__created_at__quarter + , subq_8.listing__created_at__year + , subq_8.listing__created_at__extract_year + , subq_8.listing__created_at__extract_quarter + , subq_8.listing__created_at__extract_month + , subq_8.listing__created_at__extract_day + , subq_8.listing__created_at__extract_dow + , subq_8.listing__created_at__extract_doy + , subq_8.metric_time__day + , subq_8.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.listing + , subq_8.user + , subq_8.listing__user + , subq_8.country_latest + , subq_8.is_lux_latest + , subq_8.capacity_latest + , subq_8.listing__country_latest + , subq_8.listing__is_lux_latest + , subq_8.listing__capacity_latest + , subq_8.listing__bookings + , subq_8.listings + , subq_8.largest_listing + , subq_8.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__bookings'] + -- Join Standard Outputs SELECT - subq_9.listing__bookings - , subq_9.listings + subq_7.listing__bookings AS listing__bookings + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_8.listing__bookings AS listing__bookings - , subq_2.listing AS listing - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['listing', 'listing__bookings'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['listing', 'listing__bookings'] + SELECT + subq_6.listing + , subq_6.listing__bookings + FROM ( + -- Compute Metrics via Expressions SELECT - subq_7.listing - , subq_7.listing__bookings + subq_5.listing + , subq_5.bookings AS listing__bookings FROM ( - -- Compute Metrics via Expressions + -- Aggregate Measures SELECT - subq_6.listing - , subq_6.bookings AS listing__bookings + subq_4.listing + , SUM(subq_4.bookings) AS bookings FROM ( - -- Aggregate Measures + -- Pass Only Elements: ['bookings', 'listing'] SELECT - subq_5.listing - , SUM(subq_5.bookings) AS bookings + subq_3.listing + , subq_3.bookings FROM ( - -- Pass Only Elements: ['bookings', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.bookings + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.ds_partitioned__day + , subq_2.ds_partitioned__week + , subq_2.ds_partitioned__month + , subq_2.ds_partitioned__quarter + , subq_2.ds_partitioned__year + , subq_2.ds_partitioned__extract_year + , subq_2.ds_partitioned__extract_quarter + , subq_2.ds_partitioned__extract_month + , subq_2.ds_partitioned__extract_day + , subq_2.ds_partitioned__extract_dow + , subq_2.ds_partitioned__extract_doy + , subq_2.paid_at__day + , subq_2.paid_at__week + , subq_2.paid_at__month + , subq_2.paid_at__quarter + , subq_2.paid_at__year + , subq_2.paid_at__extract_year + , subq_2.paid_at__extract_quarter + , subq_2.paid_at__extract_month + , subq_2.paid_at__extract_day + , subq_2.paid_at__extract_dow + , subq_2.paid_at__extract_doy + , subq_2.booking__ds__day + , subq_2.booking__ds__week + , subq_2.booking__ds__month + , subq_2.booking__ds__quarter + , subq_2.booking__ds__year + , subq_2.booking__ds__extract_year + , subq_2.booking__ds__extract_quarter + , subq_2.booking__ds__extract_month + , subq_2.booking__ds__extract_day + , subq_2.booking__ds__extract_dow + , subq_2.booking__ds__extract_doy + , subq_2.booking__ds_partitioned__day + , subq_2.booking__ds_partitioned__week + , subq_2.booking__ds_partitioned__month + , subq_2.booking__ds_partitioned__quarter + , subq_2.booking__ds_partitioned__year + , subq_2.booking__ds_partitioned__extract_year + , subq_2.booking__ds_partitioned__extract_quarter + , subq_2.booking__ds_partitioned__extract_month + , subq_2.booking__ds_partitioned__extract_day + , subq_2.booking__ds_partitioned__extract_dow + , subq_2.booking__ds_partitioned__extract_doy + , subq_2.booking__paid_at__day + , subq_2.booking__paid_at__week + , subq_2.booking__paid_at__month + , subq_2.booking__paid_at__quarter + , subq_2.booking__paid_at__year + , subq_2.booking__paid_at__extract_year + , subq_2.booking__paid_at__extract_quarter + , subq_2.booking__paid_at__extract_month + , subq_2.booking__paid_at__extract_day + , subq_2.booking__paid_at__extract_dow + , subq_2.booking__paid_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.guest + , subq_2.host + , subq_2.booking__listing + , subq_2.booking__guest + , subq_2.booking__host + , subq_2.is_instant + , subq_2.booking__is_instant + , subq_2.bookings + , subq_2.instant_bookings + , subq_2.booking_value + , subq_2.max_booking_value + , subq_2.min_booking_value + , subq_2.bookers + , subq_2.average_booking_value + , subq_2.referred_bookings + , subq_2.median_booking_value + , subq_2.booking_value_p99 + , subq_2.discrete_booking_value_p99 + , subq_2.approximate_continuous_booking_value_p99 + , subq_2.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_3.ds__day - , subq_3.ds__week - , subq_3.ds__month - , subq_3.ds__quarter - , subq_3.ds__year - , subq_3.ds__extract_year - , subq_3.ds__extract_quarter - , subq_3.ds__extract_month - , subq_3.ds__extract_day - , subq_3.ds__extract_dow - , subq_3.ds__extract_doy - , subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.paid_at__day - , subq_3.paid_at__week - , subq_3.paid_at__month - , subq_3.paid_at__quarter - , subq_3.paid_at__year - , subq_3.paid_at__extract_year - , subq_3.paid_at__extract_quarter - , subq_3.paid_at__extract_month - , subq_3.paid_at__extract_day - , subq_3.paid_at__extract_dow - , subq_3.paid_at__extract_doy - , subq_3.booking__ds__day - , subq_3.booking__ds__week - , subq_3.booking__ds__month - , subq_3.booking__ds__quarter - , subq_3.booking__ds__year - , subq_3.booking__ds__extract_year - , subq_3.booking__ds__extract_quarter - , subq_3.booking__ds__extract_month - , subq_3.booking__ds__extract_day - , subq_3.booking__ds__extract_dow - , subq_3.booking__ds__extract_doy - , subq_3.booking__ds_partitioned__day - , subq_3.booking__ds_partitioned__week - , subq_3.booking__ds_partitioned__month - , subq_3.booking__ds_partitioned__quarter - , subq_3.booking__ds_partitioned__year - , subq_3.booking__ds_partitioned__extract_year - , subq_3.booking__ds_partitioned__extract_quarter - , subq_3.booking__ds_partitioned__extract_month - , subq_3.booking__ds_partitioned__extract_day - , subq_3.booking__ds_partitioned__extract_dow - , subq_3.booking__ds_partitioned__extract_doy - , subq_3.booking__paid_at__day - , subq_3.booking__paid_at__week - , subq_3.booking__paid_at__month - , subq_3.booking__paid_at__quarter - , subq_3.booking__paid_at__year - , subq_3.booking__paid_at__extract_year - , subq_3.booking__paid_at__extract_quarter - , subq_3.booking__paid_at__extract_month - , subq_3.booking__paid_at__extract_day - , subq_3.booking__paid_at__extract_dow - , subq_3.booking__paid_at__extract_doy - , subq_3.ds__day AS metric_time__day - , subq_3.ds__week AS metric_time__week - , subq_3.ds__month AS metric_time__month - , subq_3.ds__quarter AS metric_time__quarter - , subq_3.ds__year AS metric_time__year - , subq_3.ds__extract_year AS metric_time__extract_year - , subq_3.ds__extract_quarter AS metric_time__extract_quarter - , subq_3.ds__extract_month AS metric_time__extract_month - , subq_3.ds__extract_day AS metric_time__extract_day - , subq_3.ds__extract_dow AS metric_time__extract_dow - , subq_3.ds__extract_doy AS metric_time__extract_doy - , subq_3.listing - , subq_3.guest - , subq_3.host - , subq_3.booking__listing - , subq_3.booking__guest - , subq_3.booking__host - , subq_3.is_instant - , subq_3.booking__is_instant - , subq_3.bookings - , subq_3.instant_bookings - , subq_3.booking_value - , subq_3.max_booking_value - , subq_3.min_booking_value - , subq_3.bookers - , subq_3.average_booking_value - , subq_3.referred_bookings - , subq_3.median_booking_value - , subq_3.booking_value_p99 - , subq_3.discrete_booking_value_p99 - , subq_3.approximate_continuous_booking_value_p99 - , subq_3.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - GROUP BY - subq_5.listing - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_2.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + GROUP BY + subq_4.listing + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_1.listing = subq_7.listing + ) subq_8 WHERE listing__bookings > 2 - ) subq_11 - ) subq_12 -) subq_13 + ) subq_9 + ) subq_10 +) subq_11 diff --git a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql index 48fed36d03..e163c214d3 100644 --- a/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_metric_filter_rendering.py/SqlQueryPlan/Trino/test_query_with_simple_metric_in_where_filter__plan0_optimized.sql @@ -6,19 +6,17 @@ SELECT SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'listing__bookings'] SELECT - subq_22.listing__bookings AS listing__bookings - , subq_16.listings AS listings + subq_19.listing__bookings AS listing__bookings + , subq_13.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing'] SELECT listing_id AS listing , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_16 + ) subq_13 LEFT OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -34,11 +32,11 @@ FROM ( listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_19 + ) subq_16 GROUP BY listing - ) subq_22 + ) subq_19 ON - subq_16.listing = subq_22.listing -) subq_24 + subq_13.listing = subq_19.listing +) subq_20 WHERE listing__bookings > 2 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml index 85181e0c43..ed5d968b08 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfp_0.xml @@ -62,7 +62,7 @@ - + @@ -117,83 +117,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -202,7 +157,7 @@ - + @@ -235,7 +190,7 @@ - + @@ -299,9 +254,9 @@ - + - + @@ -317,7 +272,7 @@ - + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfpo_0.xml index c4335096a7..0eb01cf6bd 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_conversion_metric_predicate_pushdown__dfpo_0.xml @@ -62,7 +62,7 @@ - + @@ -75,123 +75,81 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + + + + + + + + + + + + + @@ -199,7 +157,7 @@ - + @@ -232,7 +190,7 @@ - + @@ -254,9 +212,9 @@ - + - + @@ -315,7 +273,7 @@ - + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfp_0.xml index 1746fc2f94..7583c3cb21 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfp_0.xml @@ -58,7 +58,7 @@ - + @@ -113,100 +113,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfpo_0.xml index f8ffd0f705..cc2601c7f4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_cumulative_metric_predicate_pushdown__dfpo_0.xml @@ -58,7 +58,7 @@ - + @@ -71,140 +71,98 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml index 3261940531..58ddfdb414 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml @@ -125,7 +125,7 @@ - + @@ -180,93 +180,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -343,7 +294,7 @@ - + @@ -398,111 +349,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml index 870c0cd355..6bc6a4c5e4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml @@ -125,7 +125,7 @@ - + @@ -138,135 +138,86 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -342,7 +293,7 @@ - + @@ -397,111 +348,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml index ccd6572003..97d6d08be9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml @@ -165,118 +165,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - + @@ -293,8 +268,8 @@ - - + + @@ -410,136 +385,110 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -556,8 +505,8 @@ - - + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml index 339a77d3ac..13332bddb2 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml @@ -169,7 +169,7 @@ - + @@ -190,93 +190,69 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -409,136 +385,110 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -555,8 +505,8 @@ - - + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml index 0fa8c28f44..8e348736ca 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml @@ -113,7 +113,7 @@ - + @@ -168,90 +168,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -315,7 +268,7 @@ - + @@ -370,107 +323,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml index 75f907acea..4cd53b1290 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml @@ -113,7 +113,7 @@ - + @@ -126,132 +126,86 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -314,7 +268,7 @@ - + @@ -369,107 +323,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfp_0.xml index 0bcd91acb0..dafdce1114 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfp_0.xml @@ -58,7 +58,7 @@ - + @@ -108,73 +108,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfpo_0.xml index f62aef3214..b77327cfc9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_categorical_pushdown__dfpo_0.xml @@ -58,7 +58,7 @@ - + @@ -66,115 +66,86 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfp_0.xml index 454290baae..6e4e1bf1bf 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfp_0.xml @@ -56,7 +56,7 @@ - + @@ -104,72 +104,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfpo_0.xml index 402e39cc4b..9364d5ed29 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_simple_join_metric_time_pushdown_with_two_targets__dfpo_0.xml @@ -56,7 +56,7 @@ - + @@ -104,72 +104,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0.sql index 152fa655b0..97fd1b4564 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS FLOAT64) / CAST(NULLIF(subq_24.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS FLOAT64) / CAST(NULLIF(subq_22.visits, 0) AS FLOAT64) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_28000.user_id AS visitors - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day - , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week - , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month - , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter - , DATETIME_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , visits_source_src_28000.user_id AS visitors + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(visits_source_src_28000.ds, day) AS visit__ds__day + , DATETIME_TRUNC(visits_source_src_28000.ds, isoweek) AS visit__ds__week + , DATETIME_TRUNC(visits_source_src_28000.ds, month) AS visit__ds__month + , DATETIME_TRUNC(visits_source_src_28000.ds, quarter) AS visit__ds__quarter + , DATETIME_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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATETIME_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day - , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week - , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month - , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day - , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week - , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month - , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter - , DATETIME_TRUNC(users_latest_src_28000.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + DATETIME_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day + , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week + , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month + , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day + , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week + , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month + , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter + , DATETIME_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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY metric_time__day , user__home_state_latest - ) subq_9 + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , GENERATE_UUID() AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATE_SUB(CAST(subq_19.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_14.metric_time__day > DATE_SUB(CAST(subq_17.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY metric_time__day , user__home_state_latest - ) subq_23 + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY metric_time__day , user__home_state_latest -) subq_24 +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0_optimized.sql index fac0a1caaf..27f60e49d9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , GENERATE_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > DATE_SUB(CAST(subq_44.metric_time__day AS DATETIME), INTERVAL 7 day) + subq_37.metric_time__day > DATE_SUB(CAST(subq_40.metric_time__day AS DATETIME), INTERVAL 7 day) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY metric_time__day , user__home_state_latest -) subq_49 +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql index d9951a2c4a..738d306890 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > DATE_SUB(CAST(subq_2.metric_time__day AS DATETIME), INTERVAL 2 day) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY metric_time__day , listing__country_latest -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 22c9ea369d..44b0628847 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_17.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_15.ds ) AND ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 2 day) + DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 2 day) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index 4150dc08af..bd750d895a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS FLOAT64) / CAST(NULLIF(subq_12.max_booking_value, 0) AS FLOAT64) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS FLOAT64) / CAST(NULLIF(subq_11.max_booking_value, 0) AS FLOAT64) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 - ) subq_6 + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY metric_time__day -) subq_12 +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index b483bb7a26..c14baa3745 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY metric_time__day -) subq_25 +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index dd014f8c4e..6e84bfe520 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY metric_time__day , listing__country_latest - ) subq_10 + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_15.metric_time__day, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_15.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_15.metric_time__day, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_15.metric_time__day, year) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_15.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_15.metric_time__day) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATETIME_TRUNC(subq_17.metric_time__day, isoweek) AS metric_time__week - , DATETIME_TRUNC(subq_17.metric_time__day, month) AS metric_time__month - , DATETIME_TRUNC(subq_17.metric_time__day, quarter) AS metric_time__quarter - , DATETIME_TRUNC(subq_17.metric_time__day, year) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , IF(EXTRACT(dayofweek FROM subq_17.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_17.metric_time__day) - 1) AS metric_time__extract_dow - , EXTRACT(dayofyear FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_17.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 + ON + DATE_SUB(CAST(subq_15.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY metric_time__day , listing__country_latest - ) subq_28 + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY metric_time__day , listing__country_latest -) subq_33 +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index f155ad58ce..467673f052 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - DATE_SUB(CAST(subq_52.ds AS DATETIME), INTERVAL 14 day) = subq_50.metric_time__day - ) subq_54 + DATE_SUB(CAST(subq_46.ds AS DATETIME), INTERVAL 14 day) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY metric_time__day , listing__country_latest -) subq_67 +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0.sql index 73bd3e4430..530c2590ee 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY listing__country_latest -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0_optimized.sql index 9d8bd95bbf..30a396e107 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql index ec163152c8..ddeb4db614 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATETIME_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day - , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week - , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month - , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter - , DATETIME_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 - , DATETIME_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day - , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week - , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month - , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter - , DATETIME_TRUNC(users_latest_src_28000.ds, year) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , IF(EXTRACT(dayofweek FROM users_latest_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM users_latest_src_28000.ds) - 1) AS user__ds_latest__extract_dow - , EXTRACT(dayofyear FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + DATETIME_TRUNC(users_latest_src_28000.ds, day) AS ds_latest__day + , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS ds_latest__week + , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS ds_latest__month + , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS ds_latest__quarter + , DATETIME_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 + , DATETIME_TRUNC(users_latest_src_28000.ds, day) AS user__ds_latest__day + , DATETIME_TRUNC(users_latest_src_28000.ds, isoweek) AS user__ds_latest__week + , DATETIME_TRUNC(users_latest_src_28000.ds, month) AS user__ds_latest__month + , DATETIME_TRUNC(users_latest_src_28000.ds, quarter) AS user__ds_latest__quarter + , DATETIME_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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY user__home_state_latest -) subq_9 +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql index d7984aaa46..a776d02c5c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY metric_time__day , listing__country_latest - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_12.metric_time__day, isoweek) AS metric_time__week + , DATETIME_TRUNC(subq_12.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_12.metric_time__day, quarter) AS metric_time__quarter + , DATETIME_TRUNC(subq_12.metric_time__day, year) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , IF(EXTRACT(dayofweek FROM subq_12.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_12.metric_time__day) - 1) AS metric_time__extract_dow + , EXTRACT(dayofyear FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATETIME_TRUNC(subq_14.metric_time__day, isoweek) AS metric_time__week - , DATETIME_TRUNC(subq_14.metric_time__day, month) AS metric_time__month - , DATETIME_TRUNC(subq_14.metric_time__day, quarter) AS metric_time__quarter - , DATETIME_TRUNC(subq_14.metric_time__day, year) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , IF(EXTRACT(dayofweek FROM subq_14.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_14.metric_time__day) - 1) AS metric_time__extract_dow - , EXTRACT(dayofyear FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_12 - ) subq_13 - ON - DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY metric_time__day , listing__country_latest - ) subq_25 - ) subq_26 + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY metric_time__day , listing__country_latest -) subq_27 +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql index f8cd2e9126..c8af3ffcf0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - DATE_SUB(CAST(subq_43.ds AS DATETIME), INTERVAL 14 day) = subq_41.metric_time__day - ) subq_45 + DATE_SUB(CAST(subq_37.ds AS DATETIME), INTERVAL 14 day) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY metric_time__day , listing__country_latest -) subq_55 +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0.sql index 3811f60886..271e615b8e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day + , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week + , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month + , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month + , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter + , DATETIME_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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS FLOAT64) / CAST(NULLIF(subq_40.views, 0) AS FLOAT64) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS FLOAT64) / CAST(NULLIF(subq_48.views, 0) AS FLOAT64) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings + subq_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds, day) AS view__ds__day - , DATETIME_TRUNC(views_source_src_28000.ds, isoweek) AS view__ds__week - , DATETIME_TRUNC(views_source_src_28000.ds, month) AS view__ds__month - , DATETIME_TRUNC(views_source_src_28000.ds, quarter) AS view__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, day) AS view__ds_partitioned__day - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, isoweek) AS view__ds_partitioned__week - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, month) AS view__ds_partitioned__month - , DATETIME_TRUNC(views_source_src_28000.ds_partitioned, quarter) AS view__ds_partitioned__quarter - , DATETIME_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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY listing__capacity_latest - ) subq_46 - ) subq_47 + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY listing__capacity_latest - ) subq_48 -) subq_49 + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY listing__capacity_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index dd7995ff8a..22905b26d0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS FLOAT64) / CAST(NULLIF(subq_98.views, 0) AS FLOAT64)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS FLOAT64) / CAST(NULLIF(subq_82.views, 0) AS FLOAT64)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY listing__capacity_latest -) subq_98 +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY listing__capacity_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index c7235c2ca9..a2a2d73442 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 5a02d6faae..f1b60a40af 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql index 824f5e2479..473280edbe 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY listing__country_latest -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0.sql index b86b8a5a54..8567c48788 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY listing__country_latest -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0.sql index 4821515888..03c0e1ef02 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS DOUBLE) / CAST(NULLIF(subq_24.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS DOUBLE) / CAST(NULLIF(subq_22.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , 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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day - , subq_8.user__home_state_latest - ) subq_9 + subq_6.metric_time__day + , subq_6.user__home_state_latest + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , UUID() AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -7, subq_19.metric_time__day) + subq_14.metric_time__day > DATEADD(day, -7, subq_17.metric_time__day) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY - subq_22.metric_time__day - , subq_22.user__home_state_latest - ) subq_23 + subq_20.metric_time__day + , subq_20.user__home_state_latest + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) -) subq_24 + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0_optimized.sql index 4c666da226..9bce198066 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > DATEADD(day, -7, subq_44.metric_time__day) + subq_37.metric_time__day > DATEADD(day, -7, subq_40.metric_time__day) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) -) subq_49 + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql index 60823e39c5..75ee3b1826 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - , subq_12.listing__country_latest -) subq_13 + subq_10.metric_time__day + , subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 4ca92ec05c..29e9a90e58 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_17.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index ec5b0ce2cf..89077f2f30 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_12.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_11.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 6f2a446f78..0c6ee58285 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index f5b25b0aba..bbdca1833d 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_15.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_15.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_15.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_15.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_15.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_17.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_17.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_17.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_17.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_17.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 - ) subq_16 - ON - DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_13 + ) subq_14 + ON + DATEADD(day, -14, subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY - subq_27.metric_time__day - , subq_27.listing__country_latest - ) subq_28 + subq_23.metric_time__day + , subq_23.listing__country_latest + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) -) subq_33 + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 8cea815a63..40d7f1621a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day - ) subq_54 + DATEADD(day, -14, subq_46.ds) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) -) subq_67 + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0.sql index e46f00634c..d641126e39 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0_optimized.sql index b5d0efe756..6151674d33 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql index a7891018d6..d401c425ce 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.user__home_state_latest -) subq_9 + subq_6.user__home_state_latest +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql index 3d647dff0b..072a3fc3d0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 - ) subq_11 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_12.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_12.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_12.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM subq_12.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_14.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_14.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_14.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_14.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM subq_14.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ON - DATEADD(day, -14, subq_14.metric_time__day) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + DATEADD(day, -14, subq_12.metric_time__day) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY - subq_24.metric_time__day - , subq_24.listing__country_latest - ) subq_25 - ) subq_26 + subq_20.metric_time__day + , subq_20.listing__country_latest + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) -) subq_27 + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql index f13113bba8..1f582c5c68 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day - ) subq_45 + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) -) subq_55 + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0.sql index 435b246d65..2132246f20 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + subq_7.listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , 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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + subq_17.listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - subq_9.listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + subq_27.listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - subq_21.listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS DOUBLE) / CAST(NULLIF(subq_48.views, 0) AS DOUBLE) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs - SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - subq_33.listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY - subq_45.listing__capacity_latest - ) subq_46 - ) subq_47 + subq_37.listing__capacity_latest + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) - ) subq_48 -) subq_49 + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index 2ca354329c..9985ab9657 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS DOUBLE) / CAST(NULLIF(subq_98.views, 0) AS DOUBLE)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS DOUBLE) / CAST(NULLIF(subq_82.views, 0) AS DOUBLE)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) -) subq_98 + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 2fc46046d3..534003a967 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 6e8a46fe3b..8892599ad9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql index 01ed482fcc..b9fc011ec1 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0.sql index 30e99fa656..aaed2b5cee 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0.sql index 664dc7ad65..eb54cfea0d 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_22.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , 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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day - , subq_8.user__home_state_latest - ) subq_9 + subq_6.metric_time__day + , subq_6.user__home_state_latest + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , GEN_RANDOM_UUID() AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > subq_19.metric_time__day - MAKE_INTERVAL(days => 7) + subq_14.metric_time__day > subq_17.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY - subq_22.metric_time__day - , subq_22.user__home_state_latest - ) subq_23 + subq_20.metric_time__day + , subq_20.user__home_state_latest + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) -) subq_24 + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0_optimized.sql index caa1575854..58a163cdc0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , GEN_RANDOM_UUID() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > subq_44.metric_time__day - MAKE_INTERVAL(days => 7) + subq_37.metric_time__day > subq_40.metric_time__day - MAKE_INTERVAL(days => 7) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) -) subq_49 + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql index 4b3816415d..845f253d70 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > subq_2.metric_time__day - MAKE_INTERVAL(days => 2) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - , subq_12.listing__country_latest -) subq_13 + subq_10.metric_time__day + , subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index aa698dcbbd..eb3b132b63 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_17.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_15.ds - MAKE_INTERVAL(days => 2) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index b8e0778598..e1d5475987 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_11.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 78c0c33a50..1134b50986 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 642229ed86..b57856b382 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_15.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_15.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_15.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_15.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_15.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_17.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_17.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_17.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_17.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , EXTRACT(isodow FROM subq_17.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 - ) subq_16 - ON - subq_17.metric_time__day - MAKE_INTERVAL(days => 14) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_13 + ) subq_14 + ON + subq_15.metric_time__day - MAKE_INTERVAL(days => 14) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY - subq_27.metric_time__day - , subq_27.listing__country_latest - ) subq_28 + subq_23.metric_time__day + , subq_23.listing__country_latest + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) -) subq_33 + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 68cacecfd5..68b55168cd 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - subq_52.ds - MAKE_INTERVAL(days => 14) = subq_50.metric_time__day - ) subq_54 + subq_46.ds - MAKE_INTERVAL(days => 14) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) -) subq_67 + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0.sql index a15d93b916..2385eef342 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0_optimized.sql index b5d0efe756..6151674d33 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql index 9dd9bdab7c..13e98ddaee 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(isodow FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.user__home_state_latest -) subq_9 + subq_6.user__home_state_latest +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql index d81e5cd4d7..1f857e64c5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 - ) subq_11 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_12.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_12.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_12.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , EXTRACT(isodow FROM subq_12.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_14.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_14.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_14.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_14.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , EXTRACT(isodow FROM subq_14.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ON - subq_14.metric_time__day - MAKE_INTERVAL(days => 14) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + subq_12.metric_time__day - MAKE_INTERVAL(days => 14) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY - subq_24.metric_time__day - , subq_24.listing__country_latest - ) subq_25 - ) subq_26 + subq_20.metric_time__day + , subq_20.listing__country_latest + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) -) subq_27 + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql index a4320515ef..56637d4670 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - subq_43.ds - MAKE_INTERVAL(days => 14) = subq_41.metric_time__day - ) subq_45 + subq_37.ds - MAKE_INTERVAL(days => 14) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) -) subq_55 + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0.sql index 4186e8bfd4..22af9fe80b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + subq_7.listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , 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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + subq_17.listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - subq_9.listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + subq_27.listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - subq_21.listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_48.views, 0) AS DOUBLE PRECISION) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs - SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - subq_33.listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY - subq_45.listing__capacity_latest - ) subq_46 - ) subq_47 + subq_37.listing__capacity_latest + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) - ) subq_48 -) subq_49 + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index 5102f461dc..7028dcf89e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_98.views, 0) AS DOUBLE PRECISION)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_82.views, 0) AS DOUBLE PRECISION)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) -) subq_98 + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 00f2cc5ddb..253f706615 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 6e8a46fe3b..8892599ad9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql index 5fc23ef4c0..105a08fac8 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0.sql index 8c638d3b5e..404743573f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0.sql index 7a70602ed6..b8fcd5eea2 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS DOUBLE PRECISION) / CAST(NULLIF(subq_22.visits, 0) AS DOUBLE PRECISION) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , 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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day - , subq_8.user__home_state_latest - ) subq_9 + subq_6.metric_time__day + , subq_6.user__home_state_latest + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -7, subq_19.metric_time__day) + subq_14.metric_time__day > DATEADD(day, -7, subq_17.metric_time__day) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY - subq_22.metric_time__day - , subq_22.user__home_state_latest - ) subq_23 + subq_20.metric_time__day + , subq_20.user__home_state_latest + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) -) subq_24 + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0_optimized.sql index 567729e351..81c986b881 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > DATEADD(day, -7, subq_44.metric_time__day) + subq_37.metric_time__day > DATEADD(day, -7, subq_40.metric_time__day) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) -) subq_49 + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql index 503211f4ba..3945d96860 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - , subq_12.listing__country_latest -) subq_13 + subq_10.metric_time__day + , subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 4ca92ec05c..29e9a90e58 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_17.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index db60a34d37..66674b279a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_12.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS DOUBLE PRECISION) / CAST(NULLIF(subq_11.max_booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 78c0c33a50..1134b50986 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 5122c0b31e..d38c1d6850 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_15.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_15.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_15.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_15.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_15.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_15.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_15.metric_time__day) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_17.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_17.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_17.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_17.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , CASE WHEN EXTRACT(dow FROM subq_17.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_17.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_17.metric_time__day) END AS metric_time__extract_dow - , EXTRACT(doy FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 - ) subq_16 - ON - DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_13 + ) subq_14 + ON + DATEADD(day, -14, subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY - subq_27.metric_time__day - , subq_27.listing__country_latest - ) subq_28 + subq_23.metric_time__day + , subq_23.listing__country_latest + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) -) subq_33 + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 8cea815a63..40d7f1621a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day - ) subq_54 + DATEADD(day, -14, subq_46.ds) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) -) subq_67 + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0.sql index 2f152299b1..e7233c5ae6 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0_optimized.sql index b5d0efe756..6151674d33 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql index b65ad2b95b..c3684eb57f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , CASE WHEN EXTRACT(dow FROM users_latest_src_28000.ds) = 0 THEN EXTRACT(dow FROM users_latest_src_28000.ds) + 7 ELSE EXTRACT(dow FROM users_latest_src_28000.ds) END AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.user__home_state_latest -) subq_9 + subq_6.user__home_state_latest +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql index 148e44428a..6b7dd29284 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 - ) subq_11 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_12.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_12.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_12.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , CASE WHEN EXTRACT(dow FROM subq_12.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_12.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_12.metric_time__day) END AS metric_time__extract_dow + , EXTRACT(doy FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_14.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_14.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_14.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_14.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , CASE WHEN EXTRACT(dow FROM subq_14.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_14.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_14.metric_time__day) END AS metric_time__extract_dow - , EXTRACT(doy FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ON - DATEADD(day, -14, subq_14.metric_time__day) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + DATEADD(day, -14, subq_12.metric_time__day) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY - subq_24.metric_time__day - , subq_24.listing__country_latest - ) subq_25 - ) subq_26 + subq_20.metric_time__day + , subq_20.listing__country_latest + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) -) subq_27 + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql index f13113bba8..1f582c5c68 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day - ) subq_45 + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) -) subq_55 + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0.sql index dbbc66559b..a01fb7675d 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + subq_7.listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , 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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + subq_17.listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - subq_9.listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + subq_27.listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - subq_21.listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_48.views, 0) AS DOUBLE PRECISION) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs - SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - subq_33.listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY - subq_45.listing__capacity_latest - ) subq_46 - ) subq_47 + subq_37.listing__capacity_latest + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) - ) subq_48 -) subq_49 + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index 5102f461dc..7028dcf89e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_98.views, 0) AS DOUBLE PRECISION)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_82.views, 0) AS DOUBLE PRECISION)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) -) subq_98 + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 97481222b4..155a4b7f42 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 6e8a46fe3b..8892599ad9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql index 0419ff0896..ecd8552c60 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0.sql index c2b3bf1c19..ed5ec92c9b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0.sql index 2efc5047fe..da151b644f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS DOUBLE) / CAST(NULLIF(subq_24.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS DOUBLE) / CAST(NULLIF(subq_22.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , 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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day - , subq_8.user__home_state_latest - ) subq_9 + subq_6.metric_time__day + , subq_6.user__home_state_latest + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , UUID_STRING() AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -7, subq_19.metric_time__day) + subq_14.metric_time__day > DATEADD(day, -7, subq_17.metric_time__day) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY - subq_22.metric_time__day - , subq_22.user__home_state_latest - ) subq_23 + subq_20.metric_time__day + , subq_20.user__home_state_latest + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) -) subq_24 + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0_optimized.sql index 581340ed0f..24457c9887 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , UUID_STRING() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > DATEADD(day, -7, subq_44.metric_time__day) + subq_37.metric_time__day > DATEADD(day, -7, subq_40.metric_time__day) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) -) subq_49 + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql index 3e68c769a7..04651b2347 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > DATEADD(day, -2, subq_2.metric_time__day) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - , subq_12.listing__country_latest -) subq_13 + subq_10.metric_time__day + , subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 4ca92ec05c..29e9a90e58 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_17.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index 12e1068276..e1536572cb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_12.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_11.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 6f2a446f78..0c6ee58285 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 99537dad6a..eeffd24149 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_15.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_15.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_15.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_15.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_15.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_17.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_17.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_17.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_17.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , EXTRACT(dayofweekiso FROM subq_17.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 - ) subq_16 - ON - DATEADD(day, -14, subq_17.metric_time__day) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_13 + ) subq_14 + ON + DATEADD(day, -14, subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY - subq_27.metric_time__day - , subq_27.listing__country_latest - ) subq_28 + subq_23.metric_time__day + , subq_23.listing__country_latest + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) -) subq_33 + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 8cea815a63..40d7f1621a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day - ) subq_54 + DATEADD(day, -14, subq_46.ds) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) -) subq_67 + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0.sql index 22832d0a62..4954be4c18 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0_optimized.sql index b5d0efe756..6151674d33 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql index d02ed59ec0..b2318240c7 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(dayofweekiso FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.user__home_state_latest -) subq_9 + subq_6.user__home_state_latest +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql index 51e8d74fc0..0b919f0357 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 - ) subq_11 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_12.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_12.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_12.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , EXTRACT(dayofweekiso FROM subq_12.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_14.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_14.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_14.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_14.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , EXTRACT(dayofweekiso FROM subq_14.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ON - DATEADD(day, -14, subq_14.metric_time__day) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + DATEADD(day, -14, subq_12.metric_time__day) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY - subq_24.metric_time__day - , subq_24.listing__country_latest - ) subq_25 - ) subq_26 + subq_20.metric_time__day + , subq_20.listing__country_latest + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) -) subq_27 + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql index f13113bba8..1f582c5c68 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day - ) subq_45 + DATEADD(day, -14, subq_37.ds) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) -) subq_55 + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0.sql index ad35b4be09..c720e086c7 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + subq_7.listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , 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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + subq_17.listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - subq_9.listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + subq_27.listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - subq_21.listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS DOUBLE) / CAST(NULLIF(subq_48.views, 0) AS DOUBLE) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs - SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - subq_33.listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY - subq_45.listing__capacity_latest - ) subq_46 - ) subq_47 + subq_37.listing__capacity_latest + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) - ) subq_48 -) subq_49 + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index 2ca354329c..9985ab9657 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS DOUBLE) / CAST(NULLIF(subq_98.views, 0) AS DOUBLE)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS DOUBLE) / CAST(NULLIF(subq_82.views, 0) AS DOUBLE)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) -) subq_98 + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 39bd6a81fe..139122ca06 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 6e8a46fe3b..8892599ad9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql index a42afda3af..acde939d1b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0.sql index 1a5ca51d1b..d36f7509e5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0.sql index fc7c8fd64e..b9c90e096a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0.sql @@ -1,392 +1,451 @@ -- Compute Metrics via Expressions SELECT - subq_24.metric_time__day - , subq_24.user__home_state_latest - , CAST(subq_24.buys AS DOUBLE) / CAST(NULLIF(subq_24.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days + subq_22.metric_time__day + , subq_22.user__home_state_latest + , CAST(subq_22.buys AS DOUBLE) / CAST(NULLIF(subq_22.visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) AS metric_time__day - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) AS user__home_state_latest - , MAX(subq_9.visits) AS visits - , MAX(subq_23.buys) AS buys + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) AS metric_time__day + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) AS user__home_state_latest + , MAX(subq_7.visits) AS visits + , MAX(subq_21.buys) AS buys FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , subq_8.user__home_state_latest - , SUM(subq_8.visits) AS visits + subq_6.metric_time__day + , subq_6.user__home_state_latest + , SUM(subq_6.visits) AS visits FROM ( -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.user__home_state_latest - , subq_7.visits + subq_5.metric_time__day + , subq_5.user__home_state_latest + , subq_5.visits FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.visit__referrer_id - , subq_6.user__home_state_latest - , subq_6.visits + 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.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.user + , subq_4.session + , subq_4.visit__user + , subq_4.visit__session + , subq_4.referrer_id + , subq_4.visit__referrer_id + , subq_4.user__home_state_latest + , subq_4.visits + , subq_4.visitors FROM ( - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.visit__referrer_id - , subq_5.user__home_state_latest - , subq_5.visits + subq_3.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_1.visit__ds__week AS visit__ds__week + , subq_1.visit__ds__month AS visit__ds__month + , subq_1.visit__ds__quarter AS visit__ds__quarter + , subq_1.visit__ds__year AS visit__ds__year + , subq_1.visit__ds__extract_year AS visit__ds__extract_year + , subq_1.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_1.visit__ds__extract_month AS visit__ds__extract_month + , subq_1.visit__ds__extract_day AS visit__ds__extract_day + , subq_1.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_1.visit__ds__extract_doy AS visit__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.session AS session + , subq_1.visit__user AS visit__user + , subq_1.visit__session AS visit__session + , subq_1.referrer_id AS referrer_id + , subq_1.visit__referrer_id AS visit__referrer_id + , subq_1.visits AS visits + , subq_1.visitors AS visitors FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.user AS user - , subq_2.visit__referrer_id AS visit__referrer_id - , subq_2.visits AS visits + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.visit__ds__day + , subq_0.visit__ds__week + , subq_0.visit__ds__month + , subq_0.visit__ds__quarter + , subq_0.visit__ds__year + , subq_0.visit__ds__extract_year + , subq_0.visit__ds__extract_quarter + , subq_0.visit__ds__extract_month + , subq_0.visit__ds__extract_day + , subq_0.visit__ds__extract_dow + , subq_0.visit__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.user + , subq_0.session + , subq_0.visit__user + , subq_0.visit__session + , subq_0.referrer_id + , subq_0.visit__referrer_id + , subq_0.visits + , subq_0.visitors FROM ( - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] + -- Read Elements From Semantic Model 'visits_source' SELECT - subq_1.metric_time__day - , subq_1.user - , subq_1.visit__referrer_id - , subq_1.visits - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.visit__ds__day - , subq_0.visit__ds__week - , subq_0.visit__ds__month - , subq_0.visit__ds__quarter - , subq_0.visit__ds__year - , subq_0.visit__ds__extract_year - , subq_0.visit__ds__extract_quarter - , subq_0.visit__ds__extract_month - , subq_0.visit__ds__extract_day - , subq_0.visit__ds__extract_dow - , subq_0.visit__ds__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.user - , subq_0.session - , subq_0.visit__user - , subq_0.visit__session - , subq_0.referrer_id - , subq_0.visit__referrer_id - , subq_0.visits - , subq_0.visitors - FROM ( - -- Read Elements From Semantic Model 'visits_source' - SELECT - 1 AS visits - , visits_source_src_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_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS visits + , 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_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE visit__referrer_id = '123456' - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day - , subq_8.user__home_state_latest - ) subq_9 + subq_6.metric_time__day + , subq_6.user__home_state_latest + ) subq_7 FULL OUTER JOIN ( -- Aggregate Measures SELECT - subq_22.metric_time__day - , subq_22.user__home_state_latest - , SUM(subq_22.buys) AS buys + subq_20.metric_time__day + , subq_20.user__home_state_latest + , SUM(subq_20.buys) AS buys FROM ( -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] SELECT - subq_21.metric_time__day - , subq_21.user__home_state_latest - , subq_21.buys + subq_19.metric_time__day + , subq_19.user__home_state_latest + , subq_19.buys FROM ( -- Find conversions for user within the range of 7 day SELECT - subq_20.metric_time__day - , subq_20.user - , subq_20.visit__referrer_id - , subq_20.user__home_state_latest - , subq_20.buys - , subq_20.visits + subq_18.metric_time__day + , subq_18.user + , subq_18.visit__referrer_id + , subq_18.user__home_state_latest + , subq_18.buys + , subq_18.visits FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_16.visits) OVER ( + FIRST_VALUE(subq_14.visits) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_16.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_14.visit__referrer_id) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_16.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_14.user__home_state_latest) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_16.metric_time__day) OVER ( + , FIRST_VALUE(subq_14.metric_time__day) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_16.user) OVER ( + , FIRST_VALUE(subq_14.user) OVER ( PARTITION BY - subq_19.user - , subq_19.metric_time__day - , subq_19.mf_internal_uuid - ORDER BY subq_16.metric_time__day DESC + subq_17.user + , subq_17.metric_time__day + , subq_17.mf_internal_uuid + ORDER BY subq_14.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_19.mf_internal_uuid AS mf_internal_uuid - , subq_19.buys AS buys + , subq_17.mf_internal_uuid AS mf_internal_uuid + , subq_17.buys AS buys FROM ( -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT - subq_15.metric_time__day - , subq_15.user - , subq_15.visit__referrer_id - , subq_15.user__home_state_latest - , subq_15.visits + subq_13.metric_time__day + , subq_13.user + , subq_13.visit__referrer_id + , subq_13.user__home_state_latest + , subq_13.visits FROM ( -- Constrain Output with WHERE SELECT - subq_14.ds__day - , subq_14.ds__week - , subq_14.ds__month - , subq_14.ds__quarter - , subq_14.ds__year - , subq_14.ds__extract_year - , subq_14.ds__extract_quarter - , subq_14.ds__extract_month - , subq_14.ds__extract_day - , subq_14.ds__extract_dow - , subq_14.ds__extract_doy - , subq_14.visit__ds__day - , subq_14.visit__ds__week - , subq_14.visit__ds__month - , subq_14.visit__ds__quarter - , subq_14.visit__ds__year - , subq_14.visit__ds__extract_year - , subq_14.visit__ds__extract_quarter - , subq_14.visit__ds__extract_month - , subq_14.visit__ds__extract_day - , subq_14.visit__ds__extract_dow - , subq_14.visit__ds__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.user - , subq_14.session - , subq_14.visit__user - , subq_14.visit__session - , subq_14.referrer_id - , subq_14.visit__referrer_id - , subq_14.user__home_state_latest - , subq_14.visits - , subq_14.visitors + 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.visit__ds__day + , subq_12.visit__ds__week + , subq_12.visit__ds__month + , subq_12.visit__ds__quarter + , subq_12.visit__ds__year + , subq_12.visit__ds__extract_year + , subq_12.visit__ds__extract_quarter + , subq_12.visit__ds__extract_month + , subq_12.visit__ds__extract_day + , subq_12.visit__ds__extract_dow + , subq_12.visit__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.session + , subq_12.visit__user + , subq_12.visit__session + , subq_12.referrer_id + , subq_12.visit__referrer_id + , subq_12.user__home_state_latest + , subq_12.visits + , subq_12.visitors FROM ( -- Join Standard Outputs SELECT - subq_13.home_state_latest AS user__home_state_latest - , subq_11.ds__day AS ds__day - , subq_11.ds__week AS ds__week - , subq_11.ds__month AS ds__month - , subq_11.ds__quarter AS ds__quarter - , subq_11.ds__year AS ds__year - , subq_11.ds__extract_year AS ds__extract_year - , subq_11.ds__extract_quarter AS ds__extract_quarter - , subq_11.ds__extract_month AS ds__extract_month - , subq_11.ds__extract_day AS ds__extract_day - , subq_11.ds__extract_dow AS ds__extract_dow - , subq_11.ds__extract_doy AS ds__extract_doy - , subq_11.visit__ds__day AS visit__ds__day - , subq_11.visit__ds__week AS visit__ds__week - , subq_11.visit__ds__month AS visit__ds__month - , subq_11.visit__ds__quarter AS visit__ds__quarter - , subq_11.visit__ds__year AS visit__ds__year - , subq_11.visit__ds__extract_year AS visit__ds__extract_year - , subq_11.visit__ds__extract_quarter AS visit__ds__extract_quarter - , subq_11.visit__ds__extract_month AS visit__ds__extract_month - , subq_11.visit__ds__extract_day AS visit__ds__extract_day - , subq_11.visit__ds__extract_dow AS visit__ds__extract_dow - , subq_11.visit__ds__extract_doy AS visit__ds__extract_doy - , subq_11.metric_time__day AS metric_time__day - , subq_11.metric_time__week AS metric_time__week - , subq_11.metric_time__month AS metric_time__month - , subq_11.metric_time__quarter AS metric_time__quarter - , subq_11.metric_time__year AS metric_time__year - , subq_11.metric_time__extract_year AS metric_time__extract_year - , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_11.metric_time__extract_month AS metric_time__extract_month - , subq_11.metric_time__extract_day AS metric_time__extract_day - , subq_11.metric_time__extract_dow AS metric_time__extract_dow - , subq_11.metric_time__extract_doy AS metric_time__extract_doy - , subq_11.user AS user - , subq_11.session AS session - , subq_11.visit__user AS visit__user - , subq_11.visit__session AS visit__session - , subq_11.referrer_id AS referrer_id - , subq_11.visit__referrer_id AS visit__referrer_id - , subq_11.visits AS visits - , subq_11.visitors AS visitors + subq_11.home_state_latest AS user__home_state_latest + , 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.visit__ds__day AS visit__ds__day + , subq_9.visit__ds__week AS visit__ds__week + , subq_9.visit__ds__month AS visit__ds__month + , subq_9.visit__ds__quarter AS visit__ds__quarter + , subq_9.visit__ds__year AS visit__ds__year + , subq_9.visit__ds__extract_year AS visit__ds__extract_year + , subq_9.visit__ds__extract_quarter AS visit__ds__extract_quarter + , subq_9.visit__ds__extract_month AS visit__ds__extract_month + , subq_9.visit__ds__extract_day AS visit__ds__extract_day + , subq_9.visit__ds__extract_dow AS visit__ds__extract_dow + , subq_9.visit__ds__extract_doy AS visit__ds__extract_doy + , subq_9.metric_time__day AS metric_time__day + , subq_9.metric_time__week AS metric_time__week + , subq_9.metric_time__month AS metric_time__month + , subq_9.metric_time__quarter AS metric_time__quarter + , subq_9.metric_time__year AS metric_time__year + , subq_9.metric_time__extract_year AS metric_time__extract_year + , subq_9.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_9.metric_time__extract_month AS metric_time__extract_month + , subq_9.metric_time__extract_day AS metric_time__extract_day + , subq_9.metric_time__extract_dow AS metric_time__extract_dow + , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_9.user AS user + , subq_9.session AS session + , subq_9.visit__user AS visit__user + , subq_9.visit__session AS visit__session + , subq_9.referrer_id AS referrer_id + , subq_9.visit__referrer_id AS visit__referrer_id + , subq_9.visits AS visits + , subq_9.visitors AS visitors FROM ( -- Metric Time Dimension 'ds' SELECT - subq_10.ds__day - , subq_10.ds__week - , subq_10.ds__month - , subq_10.ds__quarter - , subq_10.ds__year - , subq_10.ds__extract_year - , subq_10.ds__extract_quarter - , subq_10.ds__extract_month - , subq_10.ds__extract_day - , subq_10.ds__extract_dow - , subq_10.ds__extract_doy - , subq_10.visit__ds__day - , subq_10.visit__ds__week - , subq_10.visit__ds__month - , subq_10.visit__ds__quarter - , subq_10.visit__ds__year - , subq_10.visit__ds__extract_year - , subq_10.visit__ds__extract_quarter - , subq_10.visit__ds__extract_month - , subq_10.visit__ds__extract_day - , subq_10.visit__ds__extract_dow - , subq_10.visit__ds__extract_doy - , subq_10.ds__day AS metric_time__day - , subq_10.ds__week AS metric_time__week - , subq_10.ds__month AS metric_time__month - , subq_10.ds__quarter AS metric_time__quarter - , subq_10.ds__year AS metric_time__year - , subq_10.ds__extract_year AS metric_time__extract_year - , subq_10.ds__extract_quarter AS metric_time__extract_quarter - , subq_10.ds__extract_month AS metric_time__extract_month - , subq_10.ds__extract_day AS metric_time__extract_day - , subq_10.ds__extract_dow AS metric_time__extract_dow - , subq_10.ds__extract_doy AS metric_time__extract_doy - , subq_10.user - , subq_10.session - , subq_10.visit__user - , subq_10.visit__session - , subq_10.referrer_id - , subq_10.visit__referrer_id - , subq_10.visits - , subq_10.visitors + subq_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.visit__ds__day + , subq_8.visit__ds__week + , subq_8.visit__ds__month + , subq_8.visit__ds__quarter + , subq_8.visit__ds__year + , subq_8.visit__ds__extract_year + , subq_8.visit__ds__extract_quarter + , subq_8.visit__ds__extract_month + , subq_8.visit__ds__extract_day + , subq_8.visit__ds__extract_dow + , subq_8.visit__ds__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.user + , subq_8.session + , subq_8.visit__user + , subq_8.visit__session + , subq_8.referrer_id + , subq_8.visit__referrer_id + , subq_8.visits + , subq_8.visitors FROM ( -- Read Elements From Semantic Model 'visits_source' SELECT @@ -421,13 +480,13 @@ FROM ( , visits_source_src_28000.user_id AS visit__user , visits_source_src_28000.session_id AS visit__session FROM ***************************.fct_visits visits_source_src_28000 - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state_latest', 'user'] SELECT - subq_12.user - , subq_12.home_state_latest + subq_10.user + , subq_10.home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -457,123 +516,123 @@ FROM ( , users_latest_src_28000.home_state_latest AS user__home_state_latest , users_latest_src_28000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_12 - ) subq_13 + ) subq_10 + ) subq_11 ON - subq_11.user = subq_13.user - ) subq_14 + subq_9.user = subq_11.user + ) subq_12 WHERE visit__referrer_id = '123456' - ) subq_15 - ) subq_16 + ) subq_13 + ) subq_14 INNER JOIN ( -- Add column with generated UUID SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.ds_month__month - , subq_18.ds_month__quarter - , subq_18.ds_month__year - , subq_18.ds_month__extract_year - , subq_18.ds_month__extract_quarter - , subq_18.ds_month__extract_month - , subq_18.buy__ds__day - , subq_18.buy__ds__week - , subq_18.buy__ds__month - , subq_18.buy__ds__quarter - , subq_18.buy__ds__year - , subq_18.buy__ds__extract_year - , subq_18.buy__ds__extract_quarter - , subq_18.buy__ds__extract_month - , subq_18.buy__ds__extract_day - , subq_18.buy__ds__extract_dow - , subq_18.buy__ds__extract_doy - , subq_18.buy__ds_month__month - , subq_18.buy__ds_month__quarter - , subq_18.buy__ds_month__year - , subq_18.buy__ds_month__extract_year - , subq_18.buy__ds_month__extract_quarter - , subq_18.buy__ds_month__extract_month - , subq_18.metric_time__day - , subq_18.metric_time__week - , subq_18.metric_time__month - , subq_18.metric_time__quarter - , subq_18.metric_time__year - , subq_18.metric_time__extract_year - , subq_18.metric_time__extract_quarter - , subq_18.metric_time__extract_month - , subq_18.metric_time__extract_day - , subq_18.metric_time__extract_dow - , subq_18.metric_time__extract_doy - , subq_18.user - , subq_18.session_id - , subq_18.buy__user - , subq_18.buy__session_id - , subq_18.buys - , subq_18.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.ds_month__month + , subq_16.ds_month__quarter + , subq_16.ds_month__year + , subq_16.ds_month__extract_year + , subq_16.ds_month__extract_quarter + , subq_16.ds_month__extract_month + , 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.buy__ds_month__month + , subq_16.buy__ds_month__quarter + , subq_16.buy__ds_month__year + , subq_16.buy__ds_month__extract_year + , subq_16.buy__ds_month__extract_quarter + , subq_16.buy__ds_month__extract_month + , subq_16.metric_time__day + , subq_16.metric_time__week + , subq_16.metric_time__month + , subq_16.metric_time__quarter + , subq_16.metric_time__year + , subq_16.metric_time__extract_year + , subq_16.metric_time__extract_quarter + , subq_16.metric_time__extract_month + , subq_16.metric_time__extract_day + , subq_16.metric_time__extract_dow + , subq_16.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 , uuid() AS mf_internal_uuid 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_month__month - , subq_17.ds_month__quarter - , subq_17.ds_month__year - , subq_17.ds_month__extract_year - , subq_17.ds_month__extract_quarter - , subq_17.ds_month__extract_month - , 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.buy__ds_month__month - , subq_17.buy__ds_month__quarter - , subq_17.buy__ds_month__year - , subq_17.buy__ds_month__extract_year - , subq_17.buy__ds_month__extract_quarter - , subq_17.buy__ds_month__extract_month - , 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.user - , subq_17.session_id - , subq_17.buy__user - , subq_17.buy__session_id - , subq_17.buys - , subq_17.buyers + 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_month__month + , subq_15.ds_month__quarter + , subq_15.ds_month__year + , subq_15.ds_month__extract_year + , subq_15.ds_month__extract_quarter + , subq_15.ds_month__extract_month + , subq_15.buy__ds__day + , subq_15.buy__ds__week + , subq_15.buy__ds__month + , subq_15.buy__ds__quarter + , subq_15.buy__ds__year + , subq_15.buy__ds__extract_year + , subq_15.buy__ds__extract_quarter + , subq_15.buy__ds__extract_month + , subq_15.buy__ds__extract_day + , subq_15.buy__ds__extract_dow + , subq_15.buy__ds__extract_doy + , subq_15.buy__ds_month__month + , subq_15.buy__ds_month__quarter + , subq_15.buy__ds_month__year + , subq_15.buy__ds_month__extract_year + , subq_15.buy__ds_month__extract_quarter + , subq_15.buy__ds_month__extract_month + , 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.user + , subq_15.session_id + , subq_15.buy__user + , subq_15.buy__session_id + , subq_15.buys + , subq_15.buyers FROM ( -- Read Elements From Semantic Model 'buys_source' SELECT @@ -619,33 +678,33 @@ FROM ( , buys_source_src_28000.user_id AS buy__user , buys_source_src_28000.session_id AS buy__session_id FROM ***************************.fct_buys buys_source_src_28000 - ) subq_17 - ) subq_18 - ) subq_19 + ) subq_15 + ) subq_16 + ) subq_17 ON ( - subq_16.user = subq_19.user + subq_14.user = subq_17.user ) AND ( ( - subq_16.metric_time__day <= subq_19.metric_time__day + subq_14.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATE_ADD('day', -7, subq_19.metric_time__day) + subq_14.metric_time__day > DATE_ADD('day', -7, subq_17.metric_time__day) ) ) - ) subq_20 - ) subq_21 - ) subq_22 + ) subq_18 + ) subq_19 + ) subq_20 GROUP BY - subq_22.metric_time__day - , subq_22.user__home_state_latest - ) subq_23 + subq_20.metric_time__day + , subq_20.user__home_state_latest + ) subq_21 ON ( - subq_9.user__home_state_latest = subq_23.user__home_state_latest + subq_7.user__home_state_latest = subq_21.user__home_state_latest ) AND ( - subq_9.metric_time__day = subq_23.metric_time__day + subq_7.metric_time__day = subq_21.metric_time__day ) GROUP BY - COALESCE(subq_9.metric_time__day, subq_23.metric_time__day) - , COALESCE(subq_9.user__home_state_latest, subq_23.user__home_state_latest) -) subq_24 + COALESCE(subq_7.metric_time__day, subq_21.metric_time__day) + , COALESCE(subq_7.user__home_state_latest, subq_21.user__home_state_latest) +) subq_22 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0_optimized.sql index db457a0d4c..b75120b438 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_conversion_metric_query_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) AS metric_time__day - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) AS user__home_state_latest - , MAX(subq_34.visits) AS visits - , MAX(subq_48.buys) AS buys + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) AS metric_time__day + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) AS user__home_state_latest + , MAX(subq_30.visits) AS visits + , MAX(subq_44.buys) AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'user__home_state_latest', 'metric_time__day'] @@ -20,33 +20,31 @@ FROM ( , SUM(visits) AS visits FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['visits', 'user__home_state_latest', 'visit__referrer_id', 'metric_time__day'] SELECT - subq_27.metric_time__day AS metric_time__day - , subq_27.visit__referrer_id AS visit__referrer_id - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_27.visits AS visits + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_24.metric_time__day AS metric_time__day + , subq_24.visit__referrer_id AS visit__referrer_id + , subq_24.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day', 'user'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , user_id AS user , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_27 + ) subq_24 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_27.user = users_latest_src_28000.user_id - ) subq_31 + subq_24.user = users_latest_src_28000.user_id + ) subq_27 WHERE visit__referrer_id = '123456' GROUP BY metric_time__day , user__home_state_latest - ) subq_34 + ) subq_30 FULL OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'user__home_state_latest', 'metric_time__day'] @@ -58,54 +56,54 @@ FROM ( FROM ( -- Dedupe the fanout with mf_internal_uuid in the conversion data set SELECT DISTINCT - FIRST_VALUE(subq_41.visits) OVER ( + FIRST_VALUE(subq_37.visits) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visits - , FIRST_VALUE(subq_41.visit__referrer_id) OVER ( + , FIRST_VALUE(subq_37.visit__referrer_id) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS visit__referrer_id - , FIRST_VALUE(subq_41.user__home_state_latest) OVER ( + , FIRST_VALUE(subq_37.user__home_state_latest) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user__home_state_latest - , FIRST_VALUE(subq_41.metric_time__day) OVER ( + , FIRST_VALUE(subq_37.metric_time__day) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS metric_time__day - , FIRST_VALUE(subq_41.user) OVER ( + , FIRST_VALUE(subq_37.user) OVER ( PARTITION BY - subq_44.user - , subq_44.metric_time__day - , subq_44.mf_internal_uuid - ORDER BY subq_41.metric_time__day DESC + subq_40.user + , subq_40.metric_time__day + , subq_40.mf_internal_uuid + ORDER BY subq_37.metric_time__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS user - , subq_44.mf_internal_uuid AS mf_internal_uuid - , subq_44.buys AS buys + , subq_40.mf_internal_uuid AS mf_internal_uuid + , subq_40.buys AS buys FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['visits', 'visit__referrer_id', 'user__home_state_latest', 'metric_time__day', 'user'] SELECT metric_time__day - , subq_39.user + , subq_35.user , visit__referrer_id , user__home_state_latest , visits @@ -113,10 +111,10 @@ FROM ( -- Join Standard Outputs SELECT users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_36.metric_time__day AS metric_time__day - , subq_36.user AS user - , subq_36.visit__referrer_id AS visit__referrer_id - , subq_36.visits AS visits + , subq_32.metric_time__day AS metric_time__day + , subq_32.user AS user + , subq_32.visit__referrer_id AS visit__referrer_id + , subq_32.visits AS visits FROM ( -- Read Elements From Semantic Model 'visits_source' -- Metric Time Dimension 'ds' @@ -126,14 +124,14 @@ FROM ( , referrer_id AS visit__referrer_id , 1 AS visits FROM ***************************.fct_visits visits_source_src_28000 - ) subq_36 + ) subq_32 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_36.user = users_latest_src_28000.user_id - ) subq_39 + subq_32.user = users_latest_src_28000.user_id + ) subq_35 WHERE visit__referrer_id = '123456' - ) subq_41 + ) subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'buys_source' -- Metric Time Dimension 'ds' @@ -144,29 +142,29 @@ FROM ( , 1 AS buys , uuid() AS mf_internal_uuid FROM ***************************.fct_buys buys_source_src_28000 - ) subq_44 + ) subq_40 ON ( - subq_41.user = subq_44.user + subq_37.user = subq_40.user ) AND ( ( - subq_41.metric_time__day <= subq_44.metric_time__day + subq_37.metric_time__day <= subq_40.metric_time__day ) AND ( - subq_41.metric_time__day > DATE_ADD('day', -7, subq_44.metric_time__day) + subq_37.metric_time__day > DATE_ADD('day', -7, subq_40.metric_time__day) ) ) - ) subq_45 + ) subq_41 GROUP BY metric_time__day , user__home_state_latest - ) subq_48 + ) subq_44 ON ( - subq_34.user__home_state_latest = subq_48.user__home_state_latest + subq_30.user__home_state_latest = subq_44.user__home_state_latest ) AND ( - subq_34.metric_time__day = subq_48.metric_time__day + subq_30.metric_time__day = subq_44.metric_time__day ) GROUP BY - COALESCE(subq_34.metric_time__day, subq_48.metric_time__day) - , COALESCE(subq_34.user__home_state_latest, subq_48.user__home_state_latest) -) subq_49 + COALESCE(subq_30.metric_time__day, subq_44.metric_time__day) + , COALESCE(subq_30.user__home_state_latest, subq_44.user__home_state_latest) +) subq_45 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql index 269a96e3b7..d28e47c77f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -1,505 +1,678 @@ -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , subq_13.bookers AS every_two_days_bookers + subq_11.metric_time__day + , subq_11.listing__country_latest + , subq_11.bookers AS every_two_days_bookers FROM ( -- Aggregate Measures SELECT - subq_12.metric_time__day - , subq_12.listing__country_latest - , COUNT(DISTINCT subq_12.bookers) AS bookers + subq_10.metric_time__day + , subq_10.listing__country_latest + , COUNT(DISTINCT subq_10.bookers) AS bookers FROM ( -- Pass Only Elements: ['bookers', 'listing__country_latest', 'metric_time__day'] SELECT - subq_11.metric_time__day - , subq_11.listing__country_latest - , subq_11.bookers + subq_9.metric_time__day + , subq_9.listing__country_latest + , subq_9.bookers FROM ( -- Constrain Output with WHERE SELECT - subq_10.metric_time__day - , subq_10.booking__is_instant - , subq_10.listing__country_latest - , subq_10.bookers + 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.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.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.listing__country_latest + , subq_8.bookings + , subq_8.instant_bookings + , subq_8.booking_value + , subq_8.max_booking_value + , subq_8.min_booking_value + , subq_8.bookers + , subq_8.average_booking_value + , subq_8.referred_bookings + , subq_8.median_booking_value + , subq_8.booking_value_p99 + , subq_8.discrete_booking_value_p99 + , subq_8.approximate_continuous_booking_value_p99 + , subq_8.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.listing__country_latest - , subq_9.bookers + subq_7.country_latest AS listing__country_latest + , 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.metric_time__day AS metric_time__day + , subq_4.metric_time__week AS metric_time__week + , subq_4.metric_time__month AS metric_time__month + , subq_4.metric_time__quarter AS metric_time__quarter + , subq_4.metric_time__year AS metric_time__year + , subq_4.metric_time__extract_year AS metric_time__extract_year + , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_4.metric_time__extract_month AS metric_time__extract_month + , subq_4.metric_time__extract_day AS metric_time__extract_day + , subq_4.metric_time__extract_dow AS metric_time__extract_dow + , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_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 FROM ( - -- Join Standard Outputs + -- Join Self Over Time Range SELECT - subq_8.country_latest AS listing__country_latest - , subq_5.metric_time__day AS metric_time__day - , subq_5.listing AS listing - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookers AS bookers + 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 FROM ( - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_4.metric_time__day - , subq_4.listing - , subq_4.booking__is_instant - , subq_4.bookers + subq_3.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_3 + ) subq_2 + 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 FROM ( - -- Join Self Over Time Range + -- Read Elements From Semantic Model 'bookings_source' 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 - FROM ( - -- Time Spine - SELECT - subq_3.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_3 - ) subq_2 - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ON - ( - subq_1.metric_time__day <= subq_2.metric_time__day - ) AND ( - subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) - ) - ) subq_4 - ) subq_5 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + ON + ( + subq_1.metric_time__day <= subq_2.metric_time__day + ) AND ( + subq_1.metric_time__day > DATE_ADD('day', -2, subq_2.metric_time__day) + ) + ) subq_4 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_6.listing + , subq_6.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_7.listing - , subq_7.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_6 - ) subq_7 - ) subq_8 - ON - subq_5.listing = subq_8.listing - ) subq_9 - ) subq_10 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_5 + ) subq_6 + ) subq_7 + ON + subq_4.listing = subq_7.listing + ) subq_8 WHERE booking__is_instant - ) subq_11 - ) subq_12 + ) subq_9 + ) subq_10 GROUP BY - subq_12.metric_time__day - , subq_12.listing__country_latest -) subq_13 + subq_10.metric_time__day + , subq_10.listing__country_latest +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 9212dd07f5..775a0dae74 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -8,35 +8,33 @@ SELECT , COUNT(DISTINCT bookers) AS every_two_days_bookers FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookers', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_19.metric_time__day AS metric_time__day - , subq_19.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_19.bookers AS bookers + listings_latest_src_28000.country AS listing__country_latest + , subq_16.metric_time__day AS metric_time__day + , subq_16.booking__is_instant AS booking__is_instant + , subq_16.bookers AS bookers FROM ( -- Join Self Over Time Range - -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_17.ds AS metric_time__day + subq_15.ds AS metric_time__day , bookings_source_src_28000.listing_id AS listing , bookings_source_src_28000.is_instant AS booking__is_instant , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_17 + FROM ***************************.mf_time_spine subq_15 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_17.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_17.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_15.ds) ) - ) subq_19 + ) subq_16 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_19.listing = listings_latest_src_28000.listing_id -) subq_24 + subq_16.listing = listings_latest_src_28000.listing_id +) subq_20 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql index a7337a8ab5..fa2fee8e9a 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0.sql @@ -1,359 +1,447 @@ -- Compute Metrics via Expressions SELECT - subq_12.metric_time__day - , CAST(subq_12.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_12.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value + subq_11.metric_time__day + , CAST(subq_11.average_booking_value AS DOUBLE) / CAST(NULLIF(subq_11.max_booking_value, 0) AS DOUBLE) AS instant_booking_fraction_of_max_value FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , MAX(subq_6.average_booking_value) AS average_booking_value - , MAX(subq_11.max_booking_value) AS max_booking_value + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.average_booking_value) AS average_booking_value + , MAX(subq_10.max_booking_value) AS max_booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_5.metric_time__day - , subq_5.average_booking_value + subq_4.metric_time__day + , subq_4.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , AVG(subq_4.average_booking_value) AS average_booking_value + subq_3.metric_time__day + , AVG(subq_3.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.average_booking_value + subq_2.metric_time__day + , subq_2.average_booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.average_booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.max_booking_value + subq_9.metric_time__day + , subq_9.max_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , MAX(subq_9.max_booking_value) AS max_booking_value + subq_8.metric_time__day + , MAX(subq_8.max_booking_value) AS max_booking_value FROM ( -- Pass Only Elements: ['max_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.max_booking_value + subq_7.metric_time__day + , subq_7.max_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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql index 6f2a446f78..0c6ee58285 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_different_filters_on_same_measure_source_categorical_dimension__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , MAX(subq_19.average_booking_value) AS average_booking_value - , MAX(subq_24.max_booking_value) AS max_booking_value + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.average_booking_value) AS average_booking_value + , MAX(subq_22.max_booking_value) AS max_booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index e216213ca8..9a437083a5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -1,948 +1,1294 @@ -- Compute Metrics via Expressions SELECT - subq_33.metric_time__day - , subq_33.listing__country_latest + subq_29.metric_time__day + , subq_29.listing__country_latest , bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0 FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_14.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_32.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) AS metric_time__day + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_12.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_28.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.listing__country_latest - , COALESCE(subq_13.bookings, 0) AS bookings_fill_nulls_with_0 + subq_11.metric_time__day + , subq_11.listing__country_latest + , COALESCE(subq_11.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_11.metric_time__day AS metric_time__day - , subq_10.listing__country_latest AS listing__country_latest - , subq_10.bookings AS bookings + subq_9.metric_time__day AS metric_time__day + , subq_8.listing__country_latest AS listing__country_latest + , subq_8.bookings AS bookings FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_12 - ) subq_11 + subq_10.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_10 + ) subq_9 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 ON - subq_11.metric_time__day = subq_10.metric_time__day - ) subq_13 - ) subq_14 + subq_9.metric_time__day = subq_8.metric_time__day + ) subq_11 + ) subq_12 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_31.metric_time__day - , subq_31.listing__country_latest - , COALESCE(subq_31.bookings, 0) AS bookings_2_weeks_ago + subq_27.metric_time__day + , subq_27.listing__country_latest + , COALESCE(subq_27.bookings, 0) AS bookings_2_weeks_ago FROM ( -- Join to Time Spine Dataset SELECT - subq_29.metric_time__day AS metric_time__day - , subq_28.listing__country_latest AS listing__country_latest - , subq_28.bookings AS bookings + subq_25.metric_time__day AS metric_time__day + , subq_24.listing__country_latest AS listing__country_latest + , subq_24.bookings AS bookings FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_30 - ) subq_29 + subq_26.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest - , SUM(subq_27.bookings) AS bookings + subq_23.metric_time__day + , subq_23.listing__country_latest + , SUM(subq_23.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_26.metric_time__day - , subq_26.listing__country_latest - , subq_26.bookings + subq_22.metric_time__day + , subq_22.listing__country_latest + , subq_22.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_25.metric_time__day - , subq_25.booking__is_instant - , subq_25.listing__country_latest - , subq_25.bookings + subq_21.metric_time__day + , subq_21.metric_time__week + , subq_21.metric_time__month + , subq_21.metric_time__quarter + , subq_21.metric_time__year + , subq_21.metric_time__extract_year + , subq_21.metric_time__extract_quarter + , subq_21.metric_time__extract_month + , subq_21.metric_time__extract_day + , subq_21.metric_time__extract_dow + , subq_21.metric_time__extract_doy + , subq_21.ds__day + , subq_21.ds__week + , subq_21.ds__month + , subq_21.ds__quarter + , subq_21.ds__year + , subq_21.ds__extract_year + , subq_21.ds__extract_quarter + , subq_21.ds__extract_month + , subq_21.ds__extract_day + , subq_21.ds__extract_dow + , subq_21.ds__extract_doy + , subq_21.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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_24.metric_time__day - , subq_24.booking__is_instant - , subq_24.listing__country_latest - , subq_24.bookings + subq_20.country_latest AS listing__country_latest + , subq_17.metric_time__day AS metric_time__day + , subq_17.metric_time__week AS metric_time__week + , subq_17.metric_time__month AS metric_time__month + , subq_17.metric_time__quarter AS metric_time__quarter + , subq_17.metric_time__year AS metric_time__year + , subq_17.metric_time__extract_year AS metric_time__extract_year + , subq_17.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_17.metric_time__extract_month AS metric_time__extract_month + , subq_17.metric_time__extract_day AS metric_time__extract_day + , subq_17.metric_time__extract_dow AS metric_time__extract_dow + , subq_17.metric_time__extract_doy AS metric_time__extract_doy + , subq_17.ds__day AS ds__day + , subq_17.ds__week AS ds__week + , subq_17.ds__month AS ds__month + , subq_17.ds__quarter AS ds__quarter + , subq_17.ds__year AS ds__year + , subq_17.ds__extract_year AS ds__extract_year + , subq_17.ds__extract_quarter AS ds__extract_quarter + , subq_17.ds__extract_month AS ds__extract_month + , subq_17.ds__extract_day AS ds__extract_day + , subq_17.ds__extract_dow AS ds__extract_dow + , subq_17.ds__extract_doy AS ds__extract_doy + , subq_17.ds_partitioned__day AS ds_partitioned__day + , subq_17.ds_partitioned__week AS ds_partitioned__week + , subq_17.ds_partitioned__month AS ds_partitioned__month + , subq_17.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_17.ds_partitioned__year AS ds_partitioned__year + , subq_17.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_17.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_17.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_17.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_17.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_17.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_17.paid_at__day AS paid_at__day + , subq_17.paid_at__week AS paid_at__week + , subq_17.paid_at__month AS paid_at__month + , subq_17.paid_at__quarter AS paid_at__quarter + , subq_17.paid_at__year AS paid_at__year + , subq_17.paid_at__extract_year AS paid_at__extract_year + , subq_17.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_17.paid_at__extract_month AS paid_at__extract_month + , subq_17.paid_at__extract_day AS paid_at__extract_day + , subq_17.paid_at__extract_dow AS paid_at__extract_dow + , subq_17.paid_at__extract_doy AS paid_at__extract_doy + , subq_17.booking__ds__day AS booking__ds__day + , subq_17.booking__ds__week AS booking__ds__week + , subq_17.booking__ds__month AS booking__ds__month + , subq_17.booking__ds__quarter AS booking__ds__quarter + , subq_17.booking__ds__year AS booking__ds__year + , subq_17.booking__ds__extract_year AS booking__ds__extract_year + , subq_17.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_17.booking__ds__extract_month AS booking__ds__extract_month + , subq_17.booking__ds__extract_day AS booking__ds__extract_day + , subq_17.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_17.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_17.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_17.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_17.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_17.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_17.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_17.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_17.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_17.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_17.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_17.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_17.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_17.booking__paid_at__day AS booking__paid_at__day + , subq_17.booking__paid_at__week AS booking__paid_at__week + , subq_17.booking__paid_at__month AS booking__paid_at__month + , subq_17.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_17.booking__paid_at__year AS booking__paid_at__year + , subq_17.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_17.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_17.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_17.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_17.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_17.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_17.listing AS listing + , subq_17.guest AS guest + , subq_17.host AS host + , subq_17.booking__listing AS booking__listing + , subq_17.booking__guest AS booking__guest + , subq_17.booking__host AS booking__host + , subq_17.is_instant AS is_instant + , subq_17.booking__is_instant AS booking__is_instant + , subq_17.bookings AS bookings + , subq_17.instant_bookings AS instant_bookings + , subq_17.booking_value AS booking_value + , subq_17.max_booking_value AS max_booking_value + , subq_17.min_booking_value AS min_booking_value + , subq_17.bookers AS bookers + , subq_17.average_booking_value AS average_booking_value + , subq_17.referred_bookings AS referred_bookings + , subq_17.median_booking_value AS median_booking_value + , subq_17.booking_value_p99 AS booking_value_p99 + , subq_17.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_17.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_17.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_23.country_latest AS listing__country_latest - , subq_20.metric_time__day AS metric_time__day - , subq_20.listing AS listing - , subq_20.booking__is_instant AS booking__is_instant - , subq_20.bookings AS bookings + subq_15.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_15.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_15.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_15.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_15.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_15.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_15.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_15.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_15.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_15.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_15.metric_time__day) AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_19.metric_time__day - , subq_19.listing - , subq_19.booking__is_instant - , subq_19.bookings + subq_16.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + ) subq_15 + INNER JOIN ( + -- 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.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 ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_17.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_17.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_17.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_17.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_17.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_17.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_17.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_17.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_17.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_17.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_17.metric_time__day) AS metric_time__extract_doy - , 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_18.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_18 - ) subq_17 - INNER JOIN ( - -- 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.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_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 - ) subq_16 - ON - DATE_ADD('day', -14, subq_17.metric_time__day) = subq_16.metric_time__day - ) subq_19 - ) subq_20 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_13 + ) subq_14 + ON + DATE_ADD('day', -14, subq_15.metric_time__day) = subq_14.metric_time__day + ) subq_17 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_19.listing + , subq_19.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_22.listing - , subq_22.country_latest + 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.created_at__day + , subq_18.created_at__week + , subq_18.created_at__month + , subq_18.created_at__quarter + , subq_18.created_at__year + , subq_18.created_at__extract_year + , subq_18.created_at__extract_quarter + , subq_18.created_at__extract_month + , subq_18.created_at__extract_day + , subq_18.created_at__extract_dow + , subq_18.created_at__extract_doy + , subq_18.listing__ds__day + , subq_18.listing__ds__week + , subq_18.listing__ds__month + , subq_18.listing__ds__quarter + , subq_18.listing__ds__year + , subq_18.listing__ds__extract_year + , subq_18.listing__ds__extract_quarter + , subq_18.listing__ds__extract_month + , subq_18.listing__ds__extract_day + , subq_18.listing__ds__extract_dow + , subq_18.listing__ds__extract_doy + , subq_18.listing__created_at__day + , subq_18.listing__created_at__week + , subq_18.listing__created_at__month + , subq_18.listing__created_at__quarter + , subq_18.listing__created_at__year + , subq_18.listing__created_at__extract_year + , subq_18.listing__created_at__extract_quarter + , subq_18.listing__created_at__extract_month + , subq_18.listing__created_at__extract_day + , subq_18.listing__created_at__extract_dow + , subq_18.listing__created_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.user + , subq_18.listing__user + , subq_18.country_latest + , subq_18.is_lux_latest + , subq_18.capacity_latest + , subq_18.listing__country_latest + , subq_18.listing__is_lux_latest + , subq_18.listing__capacity_latest + , subq_18.listings + , subq_18.largest_listing + , subq_18.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - 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.created_at__day - , subq_21.created_at__week - , subq_21.created_at__month - , subq_21.created_at__quarter - , subq_21.created_at__year - , subq_21.created_at__extract_year - , subq_21.created_at__extract_quarter - , subq_21.created_at__extract_month - , subq_21.created_at__extract_day - , subq_21.created_at__extract_dow - , subq_21.created_at__extract_doy - , subq_21.listing__ds__day - , subq_21.listing__ds__week - , subq_21.listing__ds__month - , subq_21.listing__ds__quarter - , subq_21.listing__ds__year - , subq_21.listing__ds__extract_year - , subq_21.listing__ds__extract_quarter - , subq_21.listing__ds__extract_month - , subq_21.listing__ds__extract_day - , subq_21.listing__ds__extract_dow - , subq_21.listing__ds__extract_doy - , subq_21.listing__created_at__day - , subq_21.listing__created_at__week - , subq_21.listing__created_at__month - , subq_21.listing__created_at__quarter - , subq_21.listing__created_at__year - , subq_21.listing__created_at__extract_year - , subq_21.listing__created_at__extract_quarter - , subq_21.listing__created_at__extract_month - , subq_21.listing__created_at__extract_day - , subq_21.listing__created_at__extract_dow - , subq_21.listing__created_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.user - , subq_21.listing__user - , subq_21.country_latest - , subq_21.is_lux_latest - , subq_21.capacity_latest - , subq_21.listing__country_latest - , subq_21.listing__is_lux_latest - , subq_21.listing__capacity_latest - , subq_21.listings - , subq_21.largest_listing - , subq_21.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_21 - ) subq_22 - ) subq_23 - ON - subq_20.listing = subq_23.listing - ) subq_24 - ) subq_25 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_18 + ) subq_19 + ) subq_20 + ON + subq_17.listing = subq_20.listing + ) subq_21 WHERE booking__is_instant - ) subq_26 - ) subq_27 + ) subq_22 + ) subq_23 GROUP BY - subq_27.metric_time__day - , subq_27.listing__country_latest - ) subq_28 + subq_23.metric_time__day + , subq_23.listing__country_latest + ) subq_24 ON - subq_29.metric_time__day = subq_28.metric_time__day - ) subq_31 - ) subq_32 + subq_25.metric_time__day = subq_24.metric_time__day + ) subq_27 + ) subq_28 ON ( - subq_14.listing__country_latest = subq_32.listing__country_latest + subq_12.listing__country_latest = subq_28.listing__country_latest ) AND ( - subq_14.metric_time__day = subq_32.metric_time__day + subq_12.metric_time__day = subq_28.metric_time__day ) GROUP BY - COALESCE(subq_14.metric_time__day, subq_32.metric_time__day) - , COALESCE(subq_14.listing__country_latest, subq_32.listing__country_latest) -) subq_33 + COALESCE(subq_12.metric_time__day, subq_28.metric_time__day) + , COALESCE(subq_12.listing__country_latest, subq_28.listing__country_latest) +) subq_29 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index e7e610df25..1d1c989ff5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) AS metric_time__day - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) AS listing__country_latest - , COALESCE(MAX(subq_48.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 - , COALESCE(MAX(subq_66.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) AS metric_time__day + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) AS listing__country_latest + , COALESCE(MAX(subq_42.bookings_fill_nulls_with_0), 0) AS bookings_fill_nulls_with_0 + , COALESCE(MAX(subq_58.bookings_2_weeks_ago), 0) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -19,10 +19,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day - , subq_44.listing__country_latest AS listing__country_latest - , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + subq_40.ds AS metric_time__day + , subq_38.listing__country_latest AS listing__country_latest + , subq_38.bookings AS bookings + FROM ***************************.mf_time_spine subq_40 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -33,37 +33,35 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_36.metric_time__day AS metric_time__day - , subq_36.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_36.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_31.metric_time__day AS metric_time__day + , subq_31.booking__is_instant AS booking__is_instant + , subq_31.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_36 + ) subq_31 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_36.listing = listings_latest_src_28000.listing_id - ) subq_41 + subq_31.listing = listings_latest_src_28000.listing_id + ) subq_35 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_44 + ) subq_38 ON - subq_46.ds = subq_44.metric_time__day - ) subq_47 - ) subq_48 + subq_40.ds = subq_38.metric_time__day + ) subq_41 + ) subq_42 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT @@ -73,10 +71,10 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day - , subq_62.listing__country_latest AS listing__country_latest - , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + subq_56.ds AS metric_time__day + , subq_54.listing__country_latest AS listing__country_latest + , subq_54.bookings AS bookings + FROM ***************************.mf_time_spine subq_56 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -87,21 +85,19 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_54.metric_time__day AS metric_time__day - , subq_54.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_54.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_47.metric_time__day AS metric_time__day + , subq_47.booking__is_instant AS booking__is_instant + , subq_47.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day - , subq_50.listing AS listing - , subq_50.booking__is_instant AS booking__is_instant - , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + subq_46.ds AS metric_time__day + , subq_44.listing AS listing + , subq_44.booking__is_instant AS booking__is_instant + , subq_44.bookings AS bookings + FROM ***************************.mf_time_spine subq_46 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -111,31 +107,31 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_50 + ) subq_44 ON - DATE_ADD('day', -14, subq_52.ds) = subq_50.metric_time__day - ) subq_54 + DATE_ADD('day', -14, subq_46.ds) = subq_44.metric_time__day + ) subq_47 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_54.listing = listings_latest_src_28000.listing_id - ) subq_59 + subq_47.listing = listings_latest_src_28000.listing_id + ) subq_51 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_62 + ) subq_54 ON - subq_64.ds = subq_62.metric_time__day - ) subq_65 - ) subq_66 + subq_56.ds = subq_54.metric_time__day + ) subq_57 + ) subq_58 ON ( - subq_48.listing__country_latest = subq_66.listing__country_latest + subq_42.listing__country_latest = subq_58.listing__country_latest ) AND ( - subq_48.metric_time__day = subq_66.metric_time__day + subq_42.metric_time__day = subq_58.metric_time__day ) GROUP BY - COALESCE(subq_48.metric_time__day, subq_66.metric_time__day) - , COALESCE(subq_48.listing__country_latest, subq_66.listing__country_latest) -) subq_67 + COALESCE(subq_42.metric_time__day, subq_58.metric_time__day) + , COALESCE(subq_42.listing__country_latest, subq_58.listing__country_latest) +) subq_59 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0.sql index 3d2201c867..15778f2541 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE metric_time__day = '2024-01-01' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0_optimized.sql index b5d0efe756..6151674d33 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_metric_time_filter_with_two_targets__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_13.metric_time__day AS metric_time__day - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.metric_time__day AS metric_time__day + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE metric_time__day = '2024-01-01' GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql index 1a914de5eb..a40f6dae85 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0.sql @@ -1,222 +1,333 @@ -- Compute Metrics via Expressions SELECT - subq_9.user__home_state_latest - , subq_9.listings + subq_7.user__home_state_latest + , subq_7.listings FROM ( -- Aggregate Measures SELECT - subq_8.user__home_state_latest - , SUM(subq_8.listings) AS listings + subq_6.user__home_state_latest + , SUM(subq_6.listings) AS listings FROM ( -- Pass Only Elements: ['listings', 'user__home_state_latest'] SELECT - subq_7.user__home_state_latest - , subq_7.listings + subq_5.user__home_state_latest + , subq_5.listings FROM ( -- Constrain Output with WHERE SELECT - subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.user__home_state_latest - , subq_6.listings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.created_at__day + , subq_4.created_at__week + , subq_4.created_at__month + , subq_4.created_at__quarter + , subq_4.created_at__year + , subq_4.created_at__extract_year + , subq_4.created_at__extract_quarter + , subq_4.created_at__extract_month + , subq_4.created_at__extract_day + , subq_4.created_at__extract_dow + , subq_4.created_at__extract_doy + , subq_4.listing__ds__day + , subq_4.listing__ds__week + , subq_4.listing__ds__month + , subq_4.listing__ds__quarter + , subq_4.listing__ds__year + , subq_4.listing__ds__extract_year + , subq_4.listing__ds__extract_quarter + , subq_4.listing__ds__extract_month + , subq_4.listing__ds__extract_day + , subq_4.listing__ds__extract_dow + , subq_4.listing__ds__extract_doy + , subq_4.listing__created_at__day + , subq_4.listing__created_at__week + , subq_4.listing__created_at__month + , subq_4.listing__created_at__quarter + , subq_4.listing__created_at__year + , subq_4.listing__created_at__extract_year + , subq_4.listing__created_at__extract_quarter + , subq_4.listing__created_at__extract_month + , subq_4.listing__created_at__extract_day + , subq_4.listing__created_at__extract_dow + , subq_4.listing__created_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing + , subq_4.user + , subq_4.listing__user + , subq_4.country_latest + , subq_4.is_lux_latest + , subq_4.capacity_latest + , subq_4.listing__country_latest + , subq_4.listing__is_lux_latest + , subq_4.listing__capacity_latest + , subq_4.user__home_state_latest + , subq_4.listings + , subq_4.largest_listing + , subq_4.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] + -- Join Standard Outputs SELECT - subq_5.listing__is_lux_latest - , subq_5.listing__capacity_latest - , subq_5.user__home_state_latest - , subq_5.listings + subq_3.home_state_latest AS user__home_state_latest + , 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_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.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_1.listings AS listings + , subq_1.largest_listing AS largest_listing + , subq_1.smallest_listing AS smallest_listing FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.home_state_latest AS user__home_state_latest - , subq_2.user AS user - , subq_2.listing__is_lux_latest AS listing__is_lux_latest - , subq_2.listing__capacity_latest AS listing__capacity_latest - , subq_2.listings AS listings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.created_at__day + , subq_0.created_at__week + , subq_0.created_at__month + , subq_0.created_at__quarter + , subq_0.created_at__year + , subq_0.created_at__extract_year + , subq_0.created_at__extract_quarter + , subq_0.created_at__extract_month + , subq_0.created_at__extract_day + , subq_0.created_at__extract_dow + , subq_0.created_at__extract_doy + , subq_0.listing__ds__day + , subq_0.listing__ds__week + , subq_0.listing__ds__month + , subq_0.listing__ds__quarter + , subq_0.listing__ds__year + , subq_0.listing__ds__extract_year + , subq_0.listing__ds__extract_quarter + , subq_0.listing__ds__extract_month + , subq_0.listing__ds__extract_day + , subq_0.listing__ds__extract_dow + , subq_0.listing__ds__extract_doy + , subq_0.listing__created_at__day + , subq_0.listing__created_at__week + , subq_0.listing__created_at__month + , subq_0.listing__created_at__quarter + , subq_0.listing__created_at__year + , subq_0.listing__created_at__extract_year + , subq_0.listing__created_at__extract_quarter + , subq_0.listing__created_at__extract_month + , subq_0.listing__created_at__extract_day + , subq_0.listing__created_at__extract_dow + , subq_0.listing__created_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.user + , subq_0.listing__user + , subq_0.country_latest + , subq_0.is_lux_latest + , subq_0.capacity_latest + , subq_0.listing__country_latest + , subq_0.listing__is_lux_latest + , subq_0.listing__capacity_latest + , subq_0.listings + , subq_0.largest_listing + , subq_0.smallest_listing FROM ( - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_1.user - , subq_1.listing__is_lux_latest - , subq_1.listing__capacity_latest - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['home_state_latest', 'user'] + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['home_state_latest', 'user'] + SELECT + subq_2.user + , subq_2.home_state_latest + FROM ( + -- Read Elements From Semantic Model 'users_latest' SELECT - subq_3.user - , subq_3.home_state_latest - FROM ( - -- Read Elements From Semantic Model 'users_latest' - SELECT - DATE_TRUNC('day', users_latest_src_28000.ds) AS ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS ds_latest__extract_doy - , users_latest_src_28000.home_state_latest - , DATE_TRUNC('day', users_latest_src_28000.ds) AS user__ds_latest__day - , DATE_TRUNC('week', users_latest_src_28000.ds) AS user__ds_latest__week - , DATE_TRUNC('month', users_latest_src_28000.ds) AS user__ds_latest__month - , DATE_TRUNC('quarter', users_latest_src_28000.ds) AS user__ds_latest__quarter - , DATE_TRUNC('year', users_latest_src_28000.ds) AS user__ds_latest__year - , EXTRACT(year FROM users_latest_src_28000.ds) AS user__ds_latest__extract_year - , EXTRACT(quarter FROM users_latest_src_28000.ds) AS user__ds_latest__extract_quarter - , EXTRACT(month FROM users_latest_src_28000.ds) AS user__ds_latest__extract_month - , EXTRACT(day FROM users_latest_src_28000.ds) AS user__ds_latest__extract_day - , EXTRACT(DAY_OF_WEEK FROM users_latest_src_28000.ds) AS user__ds_latest__extract_dow - , EXTRACT(doy FROM users_latest_src_28000.ds) AS user__ds_latest__extract_doy - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , users_latest_src_28000.user_id AS user - FROM ***************************.dim_users_latest users_latest_src_28000 - ) subq_3 - ) subq_4 - ON - subq_2.user = subq_4.user - ) subq_5 - ) subq_6 + 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_2 + ) subq_3 + ON + subq_1.user = subq_3.user + ) subq_4 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.user__home_state_latest -) subq_9 + subq_6.user__home_state_latest +) subq_7 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql index 660d3f8e29..60e6d669df 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_multiple_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,28 +7,26 @@ SELECT , SUM(listings) AS listings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['listings', 'user__home_state_latest', 'listing__is_lux_latest', 'listing__capacity_latest'] SELECT - subq_12.listing__is_lux_latest AS listing__is_lux_latest - , subq_12.listing__capacity_latest AS listing__capacity_latest - , users_latest_src_28000.home_state_latest AS user__home_state_latest - , subq_12.listings AS listings + users_latest_src_28000.home_state_latest AS user__home_state_latest + , subq_9.listing__is_lux_latest AS listing__is_lux_latest + , subq_9.listing__capacity_latest AS listing__capacity_latest + , subq_9.listings AS listings FROM ( -- Read Elements From Semantic Model 'listings_latest' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['listings', 'listing__is_lux_latest', 'listing__capacity_latest', 'user'] SELECT user_id AS user , is_lux AS listing__is_lux_latest , capacity AS listing__capacity_latest , 1 AS listings FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_users_latest users_latest_src_28000 ON - subq_12.user = users_latest_src_28000.user_id -) subq_16 + subq_9.user = users_latest_src_28000.user_id +) subq_12 WHERE listing__is_lux_latest OR listing__capacity_latest > 4 GROUP BY user__home_state_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql index ce7c5bf491..58b9768f61 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql @@ -1,918 +1,1264 @@ -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.listing__country_latest + subq_23.metric_time__day + , subq_23.listing__country_latest , bookings - bookings_2_weeks_ago AS bookings_growth_2_weeks FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) AS listing__country_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) AS listing__country_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_22.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__country_latest - , subq_10.bookings + subq_8.metric_time__day + , subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.metric_time__day + , subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.listing__country_latest - , subq_8.bookings + subq_6.metric_time__day + , subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - , subq_9.listing__country_latest - ) subq_10 - ) subq_11 + subq_7.metric_time__day + , subq_7.listing__country_latest + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_25.metric_time__day - , subq_25.listing__country_latest - , subq_25.bookings AS bookings_2_weeks_ago + subq_21.metric_time__day + , subq_21.listing__country_latest + , subq_21.bookings AS bookings_2_weeks_ago FROM ( -- Aggregate Measures SELECT - subq_24.metric_time__day - , subq_24.listing__country_latest - , SUM(subq_24.bookings) AS bookings + subq_20.metric_time__day + , subq_20.listing__country_latest + , SUM(subq_20.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] SELECT - subq_23.metric_time__day - , subq_23.listing__country_latest - , subq_23.bookings + subq_19.metric_time__day + , subq_19.listing__country_latest + , subq_19.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_22.metric_time__day - , subq_22.booking__is_instant - , subq_22.listing__country_latest - , subq_22.bookings + subq_18.metric_time__day + , subq_18.metric_time__week + , subq_18.metric_time__month + , subq_18.metric_time__quarter + , subq_18.metric_time__year + , subq_18.metric_time__extract_year + , subq_18.metric_time__extract_quarter + , subq_18.metric_time__extract_month + , subq_18.metric_time__extract_day + , subq_18.metric_time__extract_dow + , subq_18.metric_time__extract_doy + , 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.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.listing__country_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_21.metric_time__day - , subq_21.booking__is_instant - , subq_21.listing__country_latest - , subq_21.bookings + subq_17.country_latest AS listing__country_latest + , subq_14.metric_time__day AS metric_time__day + , subq_14.metric_time__week AS metric_time__week + , subq_14.metric_time__month AS metric_time__month + , subq_14.metric_time__quarter AS metric_time__quarter + , subq_14.metric_time__year AS metric_time__year + , subq_14.metric_time__extract_year AS metric_time__extract_year + , subq_14.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_14.metric_time__extract_month AS metric_time__extract_month + , subq_14.metric_time__extract_day AS metric_time__extract_day + , subq_14.metric_time__extract_dow AS metric_time__extract_dow + , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_14.ds__day AS ds__day + , subq_14.ds__week AS ds__week + , subq_14.ds__month AS ds__month + , subq_14.ds__quarter AS ds__quarter + , subq_14.ds__year AS ds__year + , subq_14.ds__extract_year AS ds__extract_year + , subq_14.ds__extract_quarter AS ds__extract_quarter + , subq_14.ds__extract_month AS ds__extract_month + , subq_14.ds__extract_day AS ds__extract_day + , subq_14.ds__extract_dow AS ds__extract_dow + , subq_14.ds__extract_doy AS ds__extract_doy + , subq_14.ds_partitioned__day AS ds_partitioned__day + , subq_14.ds_partitioned__week AS ds_partitioned__week + , subq_14.ds_partitioned__month AS ds_partitioned__month + , subq_14.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_14.ds_partitioned__year AS ds_partitioned__year + , subq_14.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_14.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_14.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_14.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_14.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_14.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_14.paid_at__day AS paid_at__day + , subq_14.paid_at__week AS paid_at__week + , subq_14.paid_at__month AS paid_at__month + , subq_14.paid_at__quarter AS paid_at__quarter + , subq_14.paid_at__year AS paid_at__year + , subq_14.paid_at__extract_year AS paid_at__extract_year + , subq_14.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_14.paid_at__extract_month AS paid_at__extract_month + , subq_14.paid_at__extract_day AS paid_at__extract_day + , subq_14.paid_at__extract_dow AS paid_at__extract_dow + , subq_14.paid_at__extract_doy AS paid_at__extract_doy + , subq_14.booking__ds__day AS booking__ds__day + , subq_14.booking__ds__week AS booking__ds__week + , subq_14.booking__ds__month AS booking__ds__month + , subq_14.booking__ds__quarter AS booking__ds__quarter + , subq_14.booking__ds__year AS booking__ds__year + , subq_14.booking__ds__extract_year AS booking__ds__extract_year + , subq_14.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_14.booking__ds__extract_month AS booking__ds__extract_month + , subq_14.booking__ds__extract_day AS booking__ds__extract_day + , subq_14.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_14.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_14.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_14.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_14.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_14.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_14.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_14.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_14.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_14.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_14.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_14.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_14.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_14.booking__paid_at__day AS booking__paid_at__day + , subq_14.booking__paid_at__week AS booking__paid_at__week + , subq_14.booking__paid_at__month AS booking__paid_at__month + , subq_14.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_14.booking__paid_at__year AS booking__paid_at__year + , subq_14.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_14.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_14.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_14.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_14.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_14.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_14.listing AS listing + , subq_14.guest AS guest + , subq_14.host AS host + , subq_14.booking__listing AS booking__listing + , subq_14.booking__guest AS booking__guest + , subq_14.booking__host AS booking__host + , subq_14.is_instant AS is_instant + , subq_14.booking__is_instant AS booking__is_instant + , subq_14.bookings AS bookings + , subq_14.instant_bookings AS instant_bookings + , subq_14.booking_value AS booking_value + , subq_14.max_booking_value AS max_booking_value + , subq_14.min_booking_value AS min_booking_value + , subq_14.bookers AS bookers + , subq_14.average_booking_value AS average_booking_value + , subq_14.referred_bookings AS referred_bookings + , subq_14.median_booking_value AS median_booking_value + , subq_14.booking_value_p99 AS booking_value_p99 + , subq_14.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_14.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_14.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Join to Time Spine Dataset SELECT - subq_20.country_latest AS listing__country_latest - , subq_17.metric_time__day AS metric_time__day - , subq_17.listing AS listing - , subq_17.booking__is_instant AS booking__is_instant - , subq_17.bookings AS bookings + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_12.metric_time__day) AS metric_time__week + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month + , DATE_TRUNC('quarter', subq_12.metric_time__day) AS metric_time__quarter + , DATE_TRUNC('year', subq_12.metric_time__day) AS metric_time__year + , EXTRACT(year FROM subq_12.metric_time__day) AS metric_time__extract_year + , EXTRACT(quarter FROM subq_12.metric_time__day) AS metric_time__extract_quarter + , EXTRACT(month FROM subq_12.metric_time__day) AS metric_time__extract_month + , EXTRACT(day FROM subq_12.metric_time__day) AS metric_time__extract_day + , EXTRACT(DAY_OF_WEEK FROM subq_12.metric_time__day) AS metric_time__extract_dow + , EXTRACT(doy FROM subq_12.metric_time__day) AS metric_time__extract_doy + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Time Spine SELECT - subq_16.metric_time__day - , subq_16.listing - , subq_16.booking__is_instant - , subq_16.bookings + subq_13.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + ) subq_12 + INNER JOIN ( + -- Metric Time Dimension 'ds' + SELECT + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Join to Time Spine Dataset + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_14.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_14.metric_time__day) AS metric_time__week - , DATE_TRUNC('month', subq_14.metric_time__day) AS metric_time__month - , DATE_TRUNC('quarter', subq_14.metric_time__day) AS metric_time__quarter - , DATE_TRUNC('year', subq_14.metric_time__day) AS metric_time__year - , EXTRACT(year FROM subq_14.metric_time__day) AS metric_time__extract_year - , EXTRACT(quarter FROM subq_14.metric_time__day) AS metric_time__extract_quarter - , EXTRACT(month FROM subq_14.metric_time__day) AS metric_time__extract_month - , EXTRACT(day FROM subq_14.metric_time__day) AS metric_time__extract_day - , EXTRACT(DAY_OF_WEEK FROM subq_14.metric_time__day) AS metric_time__extract_dow - , EXTRACT(doy FROM subq_14.metric_time__day) AS metric_time__extract_doy - , 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_15.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_15 - ) subq_14 - INNER JOIN ( - -- 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ON - DATE_ADD('day', -14, subq_14.metric_time__day) = subq_13.metric_time__day - ) subq_16 - ) subq_17 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + ON + DATE_ADD('day', -14, subq_12.metric_time__day) = subq_11.metric_time__day + ) subq_14 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_16.listing + , subq_16.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_19.listing - , subq_19.country_latest + 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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_18.ds__day - , subq_18.ds__week - , subq_18.ds__month - , subq_18.ds__quarter - , subq_18.ds__year - , subq_18.ds__extract_year - , subq_18.ds__extract_quarter - , subq_18.ds__extract_month - , subq_18.ds__extract_day - , subq_18.ds__extract_dow - , subq_18.ds__extract_doy - , subq_18.created_at__day - , subq_18.created_at__week - , subq_18.created_at__month - , subq_18.created_at__quarter - , subq_18.created_at__year - , subq_18.created_at__extract_year - , subq_18.created_at__extract_quarter - , subq_18.created_at__extract_month - , subq_18.created_at__extract_day - , subq_18.created_at__extract_dow - , subq_18.created_at__extract_doy - , subq_18.listing__ds__day - , subq_18.listing__ds__week - , subq_18.listing__ds__month - , subq_18.listing__ds__quarter - , subq_18.listing__ds__year - , subq_18.listing__ds__extract_year - , subq_18.listing__ds__extract_quarter - , subq_18.listing__ds__extract_month - , subq_18.listing__ds__extract_day - , subq_18.listing__ds__extract_dow - , subq_18.listing__ds__extract_doy - , subq_18.listing__created_at__day - , subq_18.listing__created_at__week - , subq_18.listing__created_at__month - , subq_18.listing__created_at__quarter - , subq_18.listing__created_at__year - , subq_18.listing__created_at__extract_year - , subq_18.listing__created_at__extract_quarter - , subq_18.listing__created_at__extract_month - , subq_18.listing__created_at__extract_day - , subq_18.listing__created_at__extract_dow - , subq_18.listing__created_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.user - , subq_18.listing__user - , subq_18.country_latest - , subq_18.is_lux_latest - , subq_18.capacity_latest - , subq_18.listing__country_latest - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.listings - , subq_18.largest_listing - , subq_18.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_18 - ) subq_19 - ) subq_20 - ON - subq_17.listing = subq_20.listing - ) subq_21 - ) subq_22 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_15 + ) subq_16 + ) subq_17 + ON + subq_14.listing = subq_17.listing + ) subq_18 WHERE booking__is_instant - ) subq_23 - ) subq_24 + ) subq_19 + ) subq_20 GROUP BY - subq_24.metric_time__day - , subq_24.listing__country_latest - ) subq_25 - ) subq_26 + subq_20.metric_time__day + , subq_20.listing__country_latest + ) subq_21 + ) subq_22 ON ( - subq_11.listing__country_latest = subq_26.listing__country_latest + subq_9.listing__country_latest = subq_22.listing__country_latest ) AND ( - subq_11.metric_time__day = subq_26.metric_time__day + subq_9.metric_time__day = subq_22.metric_time__day ) GROUP BY - COALESCE(subq_11.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_11.listing__country_latest, subq_26.listing__country_latest) -) subq_27 + COALESCE(subq_9.metric_time__day, subq_22.metric_time__day) + , COALESCE(subq_9.listing__country_latest, subq_22.listing__country_latest) +) subq_23 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql index ac83e4994e..bccbbae58f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -6,10 +6,10 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) AS metric_time__day - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) AS listing__country_latest - , MAX(subq_39.bookings) AS bookings - , MAX(subq_54.bookings_2_weeks_ago) AS bookings_2_weeks_ago + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) AS metric_time__day + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) AS listing__country_latest + , MAX(subq_33.bookings) AS bookings + , MAX(subq_46.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -21,33 +21,31 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_30.metric_time__day AS metric_time__day - , subq_30.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_30.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_25.metric_time__day AS metric_time__day + , subq_25.booking__is_instant AS booking__is_instant + , subq_25.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_30 + ) subq_25 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_30.listing = listings_latest_src_28000.listing_id - ) subq_35 + subq_25.listing = listings_latest_src_28000.listing_id + ) subq_29 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_39 + ) subq_33 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -59,21 +57,19 @@ FROM ( , SUM(bookings) AS bookings_2_weeks_ago FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] SELECT - subq_45.metric_time__day AS metric_time__day - , subq_45.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_45.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_38.metric_time__day AS metric_time__day + , subq_38.booking__is_instant AS booking__is_instant + , subq_38.bookings AS bookings FROM ( -- Join to Time Spine Dataset - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day - , subq_41.listing AS listing - , subq_41.booking__is_instant AS booking__is_instant - , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + subq_37.ds AS metric_time__day + , subq_35.listing AS listing + , subq_35.booking__is_instant AS booking__is_instant + , subq_35.bookings AS bookings + FROM ***************************.mf_time_spine subq_37 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -83,27 +79,27 @@ FROM ( , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_41 + ) subq_35 ON - DATE_ADD('day', -14, subq_43.ds) = subq_41.metric_time__day - ) subq_45 + DATE_ADD('day', -14, subq_37.ds) = subq_35.metric_time__day + ) subq_38 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_45.listing = listings_latest_src_28000.listing_id - ) subq_50 + subq_38.listing = listings_latest_src_28000.listing_id + ) subq_42 WHERE booking__is_instant GROUP BY metric_time__day , listing__country_latest - ) subq_54 + ) subq_46 ON ( - subq_39.listing__country_latest = subq_54.listing__country_latest + subq_33.listing__country_latest = subq_46.listing__country_latest ) AND ( - subq_39.metric_time__day = subq_54.metric_time__day + subq_33.metric_time__day = subq_46.metric_time__day ) GROUP BY - COALESCE(subq_39.metric_time__day, subq_54.metric_time__day) - , COALESCE(subq_39.listing__country_latest, subq_54.listing__country_latest) -) subq_55 + COALESCE(subq_33.metric_time__day, subq_46.metric_time__day) + , COALESCE(subq_33.listing__country_latest, subq_46.listing__country_latest) +) subq_47 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0.sql index c7a63c63af..18ca6239d1 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0.sql @@ -1,153 +1,1321 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_11.bookings) AS bookings - , MAX(subq_23.views) AS views - , MAX(subq_49.bookings_per_view) AS bookings_per_view + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views + , MAX(subq_41.bookings_per_view) AS bookings_per_view FROM ( -- Compute Metrics via Expressions SELECT - subq_10.listing__capacity_latest - , subq_10.bookings + subq_8.listing__capacity_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__capacity_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__capacity_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] SELECT - subq_8.listing__capacity_latest - , subq_8.bookings + subq_6.listing__capacity_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.metric_time__day - , subq_7.listing__is_lux_latest - , subq_7.listing__capacity_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , subq_5.listing__capacity_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.listing__capacity_latest - , subq_6.bookings + subq_4.is_lux_latest AS listing__is_lux_latest + , subq_4.capacity_latest AS listing__capacity_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_5.capacity_latest AS listing__capacity_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + , subq_3.capacity_latest + FROM ( + -- Metric Time Dimension 'ds' + SELECT + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing + FROM ( + -- Read Elements From Semantic Model 'listings_latest' + SELECT + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_6 + ) subq_7 + GROUP BY + subq_7.listing__capacity_latest + ) subq_8 +) subq_9 +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_18.listing__capacity_latest + , subq_18.views + FROM ( + -- Aggregate Measures + SELECT + subq_17.listing__capacity_latest + , SUM(subq_17.views) AS views + FROM ( + -- Pass Only Elements: ['views', 'listing__capacity_latest'] + SELECT + subq_16.listing__capacity_latest + , subq_16.views + FROM ( + -- Constrain Output with WHERE + 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.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.view__ds__day + , subq_15.view__ds__week + , subq_15.view__ds__month + , subq_15.view__ds__quarter + , subq_15.view__ds__year + , subq_15.view__ds__extract_year + , subq_15.view__ds__extract_quarter + , subq_15.view__ds__extract_month + , subq_15.view__ds__extract_day + , subq_15.view__ds__extract_dow + , subq_15.view__ds__extract_doy + , subq_15.view__ds_partitioned__day + , subq_15.view__ds_partitioned__week + , subq_15.view__ds_partitioned__month + , subq_15.view__ds_partitioned__quarter + , subq_15.view__ds_partitioned__year + , subq_15.view__ds_partitioned__extract_year + , subq_15.view__ds_partitioned__extract_quarter + , subq_15.view__ds_partitioned__extract_month + , subq_15.view__ds_partitioned__extract_day + , subq_15.view__ds_partitioned__extract_dow + , subq_15.view__ds_partitioned__extract_doy + , subq_15.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.listing + , subq_15.user + , subq_15.view__listing + , subq_15.view__user + , subq_15.listing__is_lux_latest + , subq_15.listing__capacity_latest + , subq_15.views + FROM ( + -- Join Standard Outputs + SELECT + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_14.capacity_latest AS listing__capacity_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.view__ds__day AS view__ds__day + , subq_11.view__ds__week AS view__ds__week + , subq_11.view__ds__month AS view__ds__month + , subq_11.view__ds__quarter AS view__ds__quarter + , subq_11.view__ds__year AS view__ds__year + , subq_11.view__ds__extract_year AS view__ds__extract_year + , subq_11.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_11.view__ds__extract_month AS view__ds__extract_month + , subq_11.view__ds__extract_day AS view__ds__extract_day + , subq_11.view__ds__extract_dow AS view__ds__extract_dow + , subq_11.view__ds__extract_doy AS view__ds__extract_doy + , subq_11.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_11.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_11.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_11.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_11.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_11.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_11.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_11.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_11.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_11.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_11.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.user AS user + , subq_11.view__listing AS view__listing + , subq_11.view__user AS view__user + , subq_11.views AS 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 + FROM ( + -- Read Elements From Semantic Model 'views_source' + SELECT + 1 AS views + , 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_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + , subq_13.capacity_latest + 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.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_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_11.listing = subq_14.listing + ) subq_15 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_16 + ) subq_17 + GROUP BY + subq_17.listing__capacity_latest + ) subq_18 +) subq_19 +ON + subq_9.listing__capacity_latest = subq_19.listing__capacity_latest +FULL OUTER JOIN ( + -- Compute Metrics via Expressions + SELECT + subq_40.listing__capacity_latest + , CAST(subq_40.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + FROM ( + -- Combine Aggregated Outputs + SELECT + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_29.bookings) AS bookings + , MAX(subq_39.views) AS views + FROM ( + -- Compute Metrics via Expressions + SELECT + subq_28.listing__capacity_latest + , subq_28.bookings + FROM ( + -- Aggregate Measures + SELECT + subq_27.listing__capacity_latest + , SUM(subq_27.bookings) AS bookings + FROM ( + -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] + SELECT + subq_26.listing__capacity_latest + , subq_26.bookings + FROM ( + -- Constrain Output with WHERE + SELECT + subq_25.ds__day + , subq_25.ds__week + , subq_25.ds__month + , subq_25.ds__quarter + , subq_25.ds__year + , subq_25.ds__extract_year + , subq_25.ds__extract_quarter + , subq_25.ds__extract_month + , subq_25.ds__extract_day + , subq_25.ds__extract_dow + , subq_25.ds__extract_doy + , subq_25.ds_partitioned__day + , subq_25.ds_partitioned__week + , subq_25.ds_partitioned__month + , subq_25.ds_partitioned__quarter + , subq_25.ds_partitioned__year + , subq_25.ds_partitioned__extract_year + , subq_25.ds_partitioned__extract_quarter + , subq_25.ds_partitioned__extract_month + , subq_25.ds_partitioned__extract_day + , subq_25.ds_partitioned__extract_dow + , subq_25.ds_partitioned__extract_doy + , subq_25.paid_at__day + , subq_25.paid_at__week + , subq_25.paid_at__month + , subq_25.paid_at__quarter + , subq_25.paid_at__year + , subq_25.paid_at__extract_year + , subq_25.paid_at__extract_quarter + , subq_25.paid_at__extract_month + , subq_25.paid_at__extract_day + , subq_25.paid_at__extract_dow + , subq_25.paid_at__extract_doy + , subq_25.booking__ds__day + , subq_25.booking__ds__week + , subq_25.booking__ds__month + , subq_25.booking__ds__quarter + , subq_25.booking__ds__year + , subq_25.booking__ds__extract_year + , subq_25.booking__ds__extract_quarter + , subq_25.booking__ds__extract_month + , subq_25.booking__ds__extract_day + , subq_25.booking__ds__extract_dow + , subq_25.booking__ds__extract_doy + , subq_25.booking__ds_partitioned__day + , subq_25.booking__ds_partitioned__week + , subq_25.booking__ds_partitioned__month + , subq_25.booking__ds_partitioned__quarter + , subq_25.booking__ds_partitioned__year + , subq_25.booking__ds_partitioned__extract_year + , subq_25.booking__ds_partitioned__extract_quarter + , subq_25.booking__ds_partitioned__extract_month + , subq_25.booking__ds_partitioned__extract_day + , subq_25.booking__ds_partitioned__extract_dow + , subq_25.booking__ds_partitioned__extract_doy + , subq_25.booking__paid_at__day + , subq_25.booking__paid_at__week + , subq_25.booking__paid_at__month + , subq_25.booking__paid_at__quarter + , subq_25.booking__paid_at__year + , subq_25.booking__paid_at__extract_year + , subq_25.booking__paid_at__extract_quarter + , subq_25.booking__paid_at__extract_month + , subq_25.booking__paid_at__extract_day + , subq_25.booking__paid_at__extract_dow + , subq_25.booking__paid_at__extract_doy + , subq_25.metric_time__day + , subq_25.metric_time__week + , subq_25.metric_time__month + , subq_25.metric_time__quarter + , subq_25.metric_time__year + , subq_25.metric_time__extract_year + , subq_25.metric_time__extract_quarter + , subq_25.metric_time__extract_month + , subq_25.metric_time__extract_day + , subq_25.metric_time__extract_dow + , subq_25.metric_time__extract_doy + , subq_25.listing + , subq_25.guest + , subq_25.host + , subq_25.booking__listing + , subq_25.booking__guest + , subq_25.booking__host + , subq_25.is_instant + , subq_25.booking__is_instant + , subq_25.listing__is_lux_latest + , subq_25.listing__capacity_latest + , subq_25.bookings + , subq_25.instant_bookings + , subq_25.booking_value + , subq_25.max_booking_value + , subq_25.min_booking_value + , subq_25.bookers + , subq_25.average_booking_value + , subq_25.referred_bookings + , subq_25.median_booking_value + , subq_25.booking_value_p99 + , subq_25.discrete_booking_value_p99 + , subq_25.approximate_continuous_booking_value_p99 + , subq_25.approximate_discrete_booking_value_p99 + FROM ( + -- Join Standard Outputs + SELECT + subq_24.is_lux_latest AS listing__is_lux_latest + , subq_24.capacity_latest AS listing__capacity_latest + , subq_21.ds__day AS ds__day + , subq_21.ds__week AS ds__week + , subq_21.ds__month AS ds__month + , subq_21.ds__quarter AS ds__quarter + , subq_21.ds__year AS ds__year + , subq_21.ds__extract_year AS ds__extract_year + , subq_21.ds__extract_quarter AS ds__extract_quarter + , subq_21.ds__extract_month AS ds__extract_month + , subq_21.ds__extract_day AS ds__extract_day + , subq_21.ds__extract_dow AS ds__extract_dow + , subq_21.ds__extract_doy AS ds__extract_doy + , subq_21.ds_partitioned__day AS ds_partitioned__day + , subq_21.ds_partitioned__week AS ds_partitioned__week + , subq_21.ds_partitioned__month AS ds_partitioned__month + , subq_21.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_21.ds_partitioned__year AS ds_partitioned__year + , subq_21.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_21.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_21.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_21.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_21.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_21.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_21.paid_at__day AS paid_at__day + , subq_21.paid_at__week AS paid_at__week + , subq_21.paid_at__month AS paid_at__month + , subq_21.paid_at__quarter AS paid_at__quarter + , subq_21.paid_at__year AS paid_at__year + , subq_21.paid_at__extract_year AS paid_at__extract_year + , subq_21.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_21.paid_at__extract_month AS paid_at__extract_month + , subq_21.paid_at__extract_day AS paid_at__extract_day + , subq_21.paid_at__extract_dow AS paid_at__extract_dow + , subq_21.paid_at__extract_doy AS paid_at__extract_doy + , subq_21.booking__ds__day AS booking__ds__day + , subq_21.booking__ds__week AS booking__ds__week + , subq_21.booking__ds__month AS booking__ds__month + , subq_21.booking__ds__quarter AS booking__ds__quarter + , subq_21.booking__ds__year AS booking__ds__year + , subq_21.booking__ds__extract_year AS booking__ds__extract_year + , subq_21.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_21.booking__ds__extract_month AS booking__ds__extract_month + , subq_21.booking__ds__extract_day AS booking__ds__extract_day + , subq_21.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_21.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_21.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_21.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_21.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_21.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_21.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_21.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_21.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_21.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_21.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_21.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_21.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_21.booking__paid_at__day AS booking__paid_at__day + , subq_21.booking__paid_at__week AS booking__paid_at__week + , subq_21.booking__paid_at__month AS booking__paid_at__month + , subq_21.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_21.booking__paid_at__year AS booking__paid_at__year + , subq_21.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_21.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_21.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_21.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_21.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_21.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_21.metric_time__day AS metric_time__day + , subq_21.metric_time__week AS metric_time__week + , subq_21.metric_time__month AS metric_time__month + , subq_21.metric_time__quarter AS metric_time__quarter + , subq_21.metric_time__year AS metric_time__year + , subq_21.metric_time__extract_year AS metric_time__extract_year + , subq_21.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_21.metric_time__extract_month AS metric_time__extract_month + , subq_21.metric_time__extract_day AS metric_time__extract_day + , subq_21.metric_time__extract_dow AS metric_time__extract_dow + , subq_21.metric_time__extract_doy AS metric_time__extract_doy + , subq_21.listing AS listing + , subq_21.guest AS guest + , subq_21.host AS host + , subq_21.booking__listing AS booking__listing + , subq_21.booking__guest AS booking__guest + , subq_21.booking__host AS booking__host + , subq_21.is_instant AS is_instant + , subq_21.booking__is_instant AS booking__is_instant + , subq_21.bookings AS bookings + , subq_21.instant_bookings AS instant_bookings + , subq_21.booking_value AS booking_value + , subq_21.max_booking_value AS max_booking_value + , subq_21.min_booking_value AS min_booking_value + , subq_21.bookers AS bookers + , subq_21.average_booking_value AS average_booking_value + , subq_21.referred_bookings AS referred_bookings + , subq_21.median_booking_value AS median_booking_value + , subq_21.booking_value_p99 AS booking_value_p99 + , subq_21.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_21.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_21.approximate_discrete_booking_value_p99 AS 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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -240,265 +1408,365 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_4.listing - , subq_4.is_lux_latest - , subq_4.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_20 + ) subq_21 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_23.listing + , subq_23.is_lux_latest + , subq_23.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' + -- Metric Time Dimension 'ds' SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_8 - ) subq_9 - GROUP BY - subq_9.listing__capacity_latest - ) subq_10 -) subq_11 -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_22.listing__capacity_latest - , subq_22.views - FROM ( - -- Aggregate Measures - SELECT - subq_21.listing__capacity_latest - , SUM(subq_21.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] + 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_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_21.listing = subq_24.listing + ) subq_25 + WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') + ) subq_26 + ) subq_27 + GROUP BY + subq_27.listing__capacity_latest + ) subq_28 + ) subq_29 + FULL OUTER JOIN ( + -- Compute Metrics via Expressions SELECT - subq_20.listing__capacity_latest - , subq_20.views + subq_38.listing__capacity_latest + , subq_38.views FROM ( - -- Constrain Output with WHERE + -- Aggregate Measures SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.listing__capacity_latest - , subq_19.views + subq_37.listing__capacity_latest + , SUM(subq_37.views) AS views FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] + -- Pass Only Elements: ['views', 'listing__capacity_latest'] SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.listing__capacity_latest - , subq_18.views + subq_36.listing__capacity_latest + , subq_36.views FROM ( - -- Join Standard Outputs + -- Constrain Output with WHERE SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_17.capacity_latest AS listing__capacity_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.views AS views + subq_35.ds__day + , subq_35.ds__week + , subq_35.ds__month + , subq_35.ds__quarter + , subq_35.ds__year + , subq_35.ds__extract_year + , subq_35.ds__extract_quarter + , subq_35.ds__extract_month + , subq_35.ds__extract_day + , subq_35.ds__extract_dow + , subq_35.ds__extract_doy + , subq_35.ds_partitioned__day + , subq_35.ds_partitioned__week + , subq_35.ds_partitioned__month + , subq_35.ds_partitioned__quarter + , subq_35.ds_partitioned__year + , subq_35.ds_partitioned__extract_year + , subq_35.ds_partitioned__extract_quarter + , subq_35.ds_partitioned__extract_month + , subq_35.ds_partitioned__extract_day + , subq_35.ds_partitioned__extract_dow + , subq_35.ds_partitioned__extract_doy + , subq_35.view__ds__day + , subq_35.view__ds__week + , subq_35.view__ds__month + , subq_35.view__ds__quarter + , subq_35.view__ds__year + , subq_35.view__ds__extract_year + , subq_35.view__ds__extract_quarter + , subq_35.view__ds__extract_month + , subq_35.view__ds__extract_day + , subq_35.view__ds__extract_dow + , subq_35.view__ds__extract_doy + , subq_35.view__ds_partitioned__day + , subq_35.view__ds_partitioned__week + , subq_35.view__ds_partitioned__month + , subq_35.view__ds_partitioned__quarter + , subq_35.view__ds_partitioned__year + , subq_35.view__ds_partitioned__extract_year + , subq_35.view__ds_partitioned__extract_quarter + , subq_35.view__ds_partitioned__extract_month + , subq_35.view__ds_partitioned__extract_day + , subq_35.view__ds_partitioned__extract_dow + , subq_35.view__ds_partitioned__extract_doy + , subq_35.metric_time__day + , subq_35.metric_time__week + , subq_35.metric_time__month + , subq_35.metric_time__quarter + , subq_35.metric_time__year + , subq_35.metric_time__extract_year + , subq_35.metric_time__extract_quarter + , subq_35.metric_time__extract_month + , subq_35.metric_time__extract_day + , subq_35.metric_time__extract_dow + , subq_35.metric_time__extract_doy + , subq_35.listing + , subq_35.user + , subq_35.view__listing + , subq_35.view__user + , subq_35.listing__is_lux_latest + , subq_35.listing__capacity_latest + , subq_35.views FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] + -- Join Standard Outputs SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.views + subq_34.is_lux_latest AS listing__is_lux_latest + , subq_34.capacity_latest AS listing__capacity_latest + , subq_31.ds__day AS ds__day + , subq_31.ds__week AS ds__week + , subq_31.ds__month AS ds__month + , subq_31.ds__quarter AS ds__quarter + , subq_31.ds__year AS ds__year + , subq_31.ds__extract_year AS ds__extract_year + , subq_31.ds__extract_quarter AS ds__extract_quarter + , subq_31.ds__extract_month AS ds__extract_month + , subq_31.ds__extract_day AS ds__extract_day + , subq_31.ds__extract_dow AS ds__extract_dow + , subq_31.ds__extract_doy AS ds__extract_doy + , subq_31.ds_partitioned__day AS ds_partitioned__day + , subq_31.ds_partitioned__week AS ds_partitioned__week + , subq_31.ds_partitioned__month AS ds_partitioned__month + , subq_31.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_31.ds_partitioned__year AS ds_partitioned__year + , subq_31.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_31.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_31.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_31.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_31.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_31.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_31.view__ds__day AS view__ds__day + , subq_31.view__ds__week AS view__ds__week + , subq_31.view__ds__month AS view__ds__month + , subq_31.view__ds__quarter AS view__ds__quarter + , subq_31.view__ds__year AS view__ds__year + , subq_31.view__ds__extract_year AS view__ds__extract_year + , subq_31.view__ds__extract_quarter AS view__ds__extract_quarter + , subq_31.view__ds__extract_month AS view__ds__extract_month + , subq_31.view__ds__extract_day AS view__ds__extract_day + , subq_31.view__ds__extract_dow AS view__ds__extract_dow + , subq_31.view__ds__extract_doy AS view__ds__extract_doy + , subq_31.view__ds_partitioned__day AS view__ds_partitioned__day + , subq_31.view__ds_partitioned__week AS view__ds_partitioned__week + , subq_31.view__ds_partitioned__month AS view__ds_partitioned__month + , subq_31.view__ds_partitioned__quarter AS view__ds_partitioned__quarter + , subq_31.view__ds_partitioned__year AS view__ds_partitioned__year + , subq_31.view__ds_partitioned__extract_year AS view__ds_partitioned__extract_year + , subq_31.view__ds_partitioned__extract_quarter AS view__ds_partitioned__extract_quarter + , subq_31.view__ds_partitioned__extract_month AS view__ds_partitioned__extract_month + , subq_31.view__ds_partitioned__extract_day AS view__ds_partitioned__extract_day + , subq_31.view__ds_partitioned__extract_dow AS view__ds_partitioned__extract_dow + , subq_31.view__ds_partitioned__extract_doy AS view__ds_partitioned__extract_doy + , subq_31.metric_time__day AS metric_time__day + , subq_31.metric_time__week AS metric_time__week + , subq_31.metric_time__month AS metric_time__month + , subq_31.metric_time__quarter AS metric_time__quarter + , subq_31.metric_time__year AS metric_time__year + , subq_31.metric_time__extract_year AS metric_time__extract_year + , subq_31.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_31.metric_time__extract_month AS metric_time__extract_month + , subq_31.metric_time__extract_day AS metric_time__extract_day + , subq_31.metric_time__extract_dow AS metric_time__extract_dow + , subq_31.metric_time__extract_doy AS metric_time__extract_doy + , subq_31.listing AS listing + , subq_31.user AS user + , subq_31.view__listing AS view__listing + , subq_31.view__user AS view__user + , subq_31.views AS views 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.view__ds__day - , subq_12.view__ds__week - , subq_12.view__ds__month - , subq_12.view__ds__quarter - , subq_12.view__ds__year - , subq_12.view__ds__extract_year - , subq_12.view__ds__extract_quarter - , subq_12.view__ds__extract_month - , subq_12.view__ds__extract_day - , subq_12.view__ds__extract_dow - , subq_12.view__ds__extract_doy - , subq_12.view__ds_partitioned__day - , subq_12.view__ds_partitioned__week - , subq_12.view__ds_partitioned__month - , subq_12.view__ds_partitioned__quarter - , subq_12.view__ds_partitioned__year - , subq_12.view__ds_partitioned__extract_year - , subq_12.view__ds_partitioned__extract_quarter - , subq_12.view__ds_partitioned__extract_month - , subq_12.view__ds_partitioned__extract_day - , subq_12.view__ds_partitioned__extract_dow - , subq_12.view__ds_partitioned__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.view__listing - , subq_12.view__user - , subq_12.views + subq_30.ds__day + , subq_30.ds__week + , subq_30.ds__month + , subq_30.ds__quarter + , subq_30.ds__year + , subq_30.ds__extract_year + , subq_30.ds__extract_quarter + , subq_30.ds__extract_month + , subq_30.ds__extract_day + , subq_30.ds__extract_dow + , subq_30.ds__extract_doy + , subq_30.ds_partitioned__day + , subq_30.ds_partitioned__week + , subq_30.ds_partitioned__month + , subq_30.ds_partitioned__quarter + , subq_30.ds_partitioned__year + , subq_30.ds_partitioned__extract_year + , subq_30.ds_partitioned__extract_quarter + , subq_30.ds_partitioned__extract_month + , subq_30.ds_partitioned__extract_day + , subq_30.ds_partitioned__extract_dow + , subq_30.ds_partitioned__extract_doy + , subq_30.view__ds__day + , subq_30.view__ds__week + , subq_30.view__ds__month + , subq_30.view__ds__quarter + , subq_30.view__ds__year + , subq_30.view__ds__extract_year + , subq_30.view__ds__extract_quarter + , subq_30.view__ds__extract_month + , subq_30.view__ds__extract_day + , subq_30.view__ds__extract_dow + , subq_30.view__ds__extract_doy + , subq_30.view__ds_partitioned__day + , subq_30.view__ds_partitioned__week + , subq_30.view__ds_partitioned__month + , subq_30.view__ds_partitioned__quarter + , subq_30.view__ds_partitioned__year + , subq_30.view__ds_partitioned__extract_year + , subq_30.view__ds_partitioned__extract_quarter + , subq_30.view__ds_partitioned__extract_month + , subq_30.view__ds_partitioned__extract_day + , subq_30.view__ds_partitioned__extract_dow + , subq_30.view__ds_partitioned__extract_doy + , subq_30.ds__day AS metric_time__day + , subq_30.ds__week AS metric_time__week + , subq_30.ds__month AS metric_time__month + , subq_30.ds__quarter AS metric_time__quarter + , subq_30.ds__year AS metric_time__year + , subq_30.ds__extract_year AS metric_time__extract_year + , subq_30.ds__extract_quarter AS metric_time__extract_quarter + , subq_30.ds__extract_month AS metric_time__extract_month + , subq_30.ds__extract_day AS metric_time__extract_day + , subq_30.ds__extract_dow AS metric_time__extract_dow + , subq_30.ds__extract_doy AS metric_time__extract_doy + , subq_30.listing + , subq_30.user + , subq_30.view__listing + , subq_30.view__user + , subq_30.views FROM ( -- Read Elements From Semantic Model 'views_source' SELECT @@ -552,880 +1820,164 @@ FULL OUTER JOIN ( , 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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_16.listing - , subq_16.is_lux_latest - , subq_16.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' + ) subq_30 + ) subq_31 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] 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_33.listing + , subq_33.is_lux_latest + , subq_33.capacity_latest FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_20 - ) subq_21 - GROUP BY - subq_21.listing__capacity_latest - ) subq_22 -) subq_23 -ON - subq_11.listing__capacity_latest = subq_23.listing__capacity_latest -FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_48.listing__capacity_latest - , CAST(subq_48.bookings AS DOUBLE) / CAST(NULLIF(subq_48.views, 0) AS DOUBLE) AS bookings_per_view - FROM ( - -- Combine Aggregated Outputs - SELECT - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_35.bookings) AS bookings - , MAX(subq_47.views) AS views - FROM ( - -- Compute Metrics via Expressions - SELECT - subq_34.listing__capacity_latest - , subq_34.bookings - FROM ( - -- Aggregate Measures - SELECT - subq_33.listing__capacity_latest - , SUM(subq_33.bookings) AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] - SELECT - subq_32.listing__capacity_latest - , subq_32.bookings - FROM ( - -- Constrain Output with WHERE - SELECT - subq_31.metric_time__day - , subq_31.listing__is_lux_latest - , subq_31.listing__capacity_latest - , subq_31.bookings - FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_30.metric_time__day - , subq_30.listing__is_lux_latest - , subq_30.listing__capacity_latest - , subq_30.bookings - FROM ( - -- Join Standard Outputs - SELECT - subq_29.is_lux_latest AS listing__is_lux_latest - , subq_29.capacity_latest AS listing__capacity_latest - , subq_26.metric_time__day AS metric_time__day - , subq_26.listing AS listing - , subq_26.bookings AS bookings - FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] - SELECT - subq_25.metric_time__day - , subq_25.listing - , subq_25.bookings - 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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] - SELECT - subq_28.listing - , subq_28.is_lux_latest - , subq_28.capacity_latest - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_27.ds__day - , subq_27.ds__week - , subq_27.ds__month - , subq_27.ds__quarter - , subq_27.ds__year - , subq_27.ds__extract_year - , subq_27.ds__extract_quarter - , subq_27.ds__extract_month - , subq_27.ds__extract_day - , subq_27.ds__extract_dow - , subq_27.ds__extract_doy - , subq_27.created_at__day - , subq_27.created_at__week - , subq_27.created_at__month - , subq_27.created_at__quarter - , subq_27.created_at__year - , subq_27.created_at__extract_year - , subq_27.created_at__extract_quarter - , subq_27.created_at__extract_month - , subq_27.created_at__extract_day - , subq_27.created_at__extract_dow - , subq_27.created_at__extract_doy - , subq_27.listing__ds__day - , subq_27.listing__ds__week - , subq_27.listing__ds__month - , subq_27.listing__ds__quarter - , subq_27.listing__ds__year - , subq_27.listing__ds__extract_year - , subq_27.listing__ds__extract_quarter - , subq_27.listing__ds__extract_month - , subq_27.listing__ds__extract_day - , subq_27.listing__ds__extract_dow - , subq_27.listing__ds__extract_doy - , subq_27.listing__created_at__day - , subq_27.listing__created_at__week - , subq_27.listing__created_at__month - , subq_27.listing__created_at__quarter - , subq_27.listing__created_at__year - , subq_27.listing__created_at__extract_year - , subq_27.listing__created_at__extract_quarter - , subq_27.listing__created_at__extract_month - , subq_27.listing__created_at__extract_day - , subq_27.listing__created_at__extract_dow - , subq_27.listing__created_at__extract_doy - , subq_27.ds__day AS metric_time__day - , subq_27.ds__week AS metric_time__week - , subq_27.ds__month AS metric_time__month - , subq_27.ds__quarter AS metric_time__quarter - , subq_27.ds__year AS metric_time__year - , subq_27.ds__extract_year AS metric_time__extract_year - , subq_27.ds__extract_quarter AS metric_time__extract_quarter - , subq_27.ds__extract_month AS metric_time__extract_month - , subq_27.ds__extract_day AS metric_time__extract_day - , subq_27.ds__extract_dow AS metric_time__extract_dow - , subq_27.ds__extract_doy AS metric_time__extract_doy - , subq_27.listing - , subq_27.user - , subq_27.listing__user - , subq_27.country_latest - , subq_27.is_lux_latest - , subq_27.capacity_latest - , subq_27.listing__country_latest - , subq_27.listing__is_lux_latest - , subq_27.listing__capacity_latest - , subq_27.listings - , subq_27.largest_listing - , subq_27.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_27 - ) subq_28 - ) subq_29 - ON - subq_26.listing = subq_29.listing - ) subq_30 - ) subq_31 - WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_32 - ) subq_33 - GROUP BY - subq_33.listing__capacity_latest - ) subq_34 - ) subq_35 - FULL OUTER JOIN ( - -- Compute Metrics via Expressions - SELECT - subq_46.listing__capacity_latest - , subq_46.views - FROM ( - -- Aggregate Measures - SELECT - subq_45.listing__capacity_latest - , SUM(subq_45.views) AS views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest'] - SELECT - subq_44.listing__capacity_latest - , subq_44.views - FROM ( - -- Constrain Output with WHERE - SELECT - subq_43.metric_time__day - , subq_43.listing__is_lux_latest - , subq_43.listing__capacity_latest - , subq_43.views - FROM ( - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] - SELECT - subq_42.metric_time__day - , subq_42.listing__is_lux_latest - , subq_42.listing__capacity_latest - , subq_42.views - FROM ( - -- Join Standard Outputs - SELECT - subq_41.is_lux_latest AS listing__is_lux_latest - , subq_41.capacity_latest AS listing__capacity_latest - , subq_38.metric_time__day AS metric_time__day - , subq_38.listing AS listing - , subq_38.views AS views - FROM ( - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] - SELECT - subq_37.metric_time__day - , subq_37.listing - , subq_37.views - FROM ( - -- Metric Time Dimension 'ds' - SELECT - subq_36.ds__day - , subq_36.ds__week - , subq_36.ds__month - , subq_36.ds__quarter - , subq_36.ds__year - , subq_36.ds__extract_year - , subq_36.ds__extract_quarter - , subq_36.ds__extract_month - , subq_36.ds__extract_day - , subq_36.ds__extract_dow - , subq_36.ds__extract_doy - , subq_36.ds_partitioned__day - , subq_36.ds_partitioned__week - , subq_36.ds_partitioned__month - , subq_36.ds_partitioned__quarter - , subq_36.ds_partitioned__year - , subq_36.ds_partitioned__extract_year - , subq_36.ds_partitioned__extract_quarter - , subq_36.ds_partitioned__extract_month - , subq_36.ds_partitioned__extract_day - , subq_36.ds_partitioned__extract_dow - , subq_36.ds_partitioned__extract_doy - , subq_36.view__ds__day - , subq_36.view__ds__week - , subq_36.view__ds__month - , subq_36.view__ds__quarter - , subq_36.view__ds__year - , subq_36.view__ds__extract_year - , subq_36.view__ds__extract_quarter - , subq_36.view__ds__extract_month - , subq_36.view__ds__extract_day - , subq_36.view__ds__extract_dow - , subq_36.view__ds__extract_doy - , subq_36.view__ds_partitioned__day - , subq_36.view__ds_partitioned__week - , subq_36.view__ds_partitioned__month - , subq_36.view__ds_partitioned__quarter - , subq_36.view__ds_partitioned__year - , subq_36.view__ds_partitioned__extract_year - , subq_36.view__ds_partitioned__extract_quarter - , subq_36.view__ds_partitioned__extract_month - , subq_36.view__ds_partitioned__extract_day - , subq_36.view__ds_partitioned__extract_dow - , subq_36.view__ds_partitioned__extract_doy - , subq_36.ds__day AS metric_time__day - , subq_36.ds__week AS metric_time__week - , subq_36.ds__month AS metric_time__month - , subq_36.ds__quarter AS metric_time__quarter - , subq_36.ds__year AS metric_time__year - , subq_36.ds__extract_year AS metric_time__extract_year - , subq_36.ds__extract_quarter AS metric_time__extract_quarter - , subq_36.ds__extract_month AS metric_time__extract_month - , subq_36.ds__extract_day AS metric_time__extract_day - , subq_36.ds__extract_dow AS metric_time__extract_dow - , subq_36.ds__extract_doy AS metric_time__extract_doy - , subq_36.listing - , subq_36.user - , subq_36.view__listing - , subq_36.view__user - , subq_36.views - FROM ( - -- Read Elements From Semantic Model 'views_source' - SELECT - 1 AS views - , 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_36 - ) subq_37 - ) subq_38 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_40.listing - , subq_40.is_lux_latest - , subq_40.capacity_latest + subq_32.ds__day + , subq_32.ds__week + , subq_32.ds__month + , subq_32.ds__quarter + , subq_32.ds__year + , subq_32.ds__extract_year + , subq_32.ds__extract_quarter + , subq_32.ds__extract_month + , subq_32.ds__extract_day + , subq_32.ds__extract_dow + , subq_32.ds__extract_doy + , subq_32.created_at__day + , subq_32.created_at__week + , subq_32.created_at__month + , subq_32.created_at__quarter + , subq_32.created_at__year + , subq_32.created_at__extract_year + , subq_32.created_at__extract_quarter + , subq_32.created_at__extract_month + , subq_32.created_at__extract_day + , subq_32.created_at__extract_dow + , subq_32.created_at__extract_doy + , subq_32.listing__ds__day + , subq_32.listing__ds__week + , subq_32.listing__ds__month + , subq_32.listing__ds__quarter + , subq_32.listing__ds__year + , subq_32.listing__ds__extract_year + , subq_32.listing__ds__extract_quarter + , subq_32.listing__ds__extract_month + , subq_32.listing__ds__extract_day + , subq_32.listing__ds__extract_dow + , subq_32.listing__ds__extract_doy + , subq_32.listing__created_at__day + , subq_32.listing__created_at__week + , subq_32.listing__created_at__month + , subq_32.listing__created_at__quarter + , subq_32.listing__created_at__year + , subq_32.listing__created_at__extract_year + , subq_32.listing__created_at__extract_quarter + , subq_32.listing__created_at__extract_month + , subq_32.listing__created_at__extract_day + , subq_32.listing__created_at__extract_dow + , subq_32.listing__created_at__extract_doy + , subq_32.ds__day AS metric_time__day + , subq_32.ds__week AS metric_time__week + , subq_32.ds__month AS metric_time__month + , subq_32.ds__quarter AS metric_time__quarter + , subq_32.ds__year AS metric_time__year + , subq_32.ds__extract_year AS metric_time__extract_year + , subq_32.ds__extract_quarter AS metric_time__extract_quarter + , subq_32.ds__extract_month AS metric_time__extract_month + , subq_32.ds__extract_day AS metric_time__extract_day + , subq_32.ds__extract_dow AS metric_time__extract_dow + , subq_32.ds__extract_doy AS metric_time__extract_doy + , subq_32.listing + , subq_32.user + , subq_32.listing__user + , subq_32.country_latest + , subq_32.is_lux_latest + , subq_32.capacity_latest + , subq_32.listing__country_latest + , subq_32.listing__is_lux_latest + , subq_32.listing__capacity_latest + , subq_32.listings + , subq_32.largest_listing + , subq_32.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' SELECT - subq_39.ds__day - , subq_39.ds__week - , subq_39.ds__month - , subq_39.ds__quarter - , subq_39.ds__year - , subq_39.ds__extract_year - , subq_39.ds__extract_quarter - , subq_39.ds__extract_month - , subq_39.ds__extract_day - , subq_39.ds__extract_dow - , subq_39.ds__extract_doy - , subq_39.created_at__day - , subq_39.created_at__week - , subq_39.created_at__month - , subq_39.created_at__quarter - , subq_39.created_at__year - , subq_39.created_at__extract_year - , subq_39.created_at__extract_quarter - , subq_39.created_at__extract_month - , subq_39.created_at__extract_day - , subq_39.created_at__extract_dow - , subq_39.created_at__extract_doy - , subq_39.listing__ds__day - , subq_39.listing__ds__week - , subq_39.listing__ds__month - , subq_39.listing__ds__quarter - , subq_39.listing__ds__year - , subq_39.listing__ds__extract_year - , subq_39.listing__ds__extract_quarter - , subq_39.listing__ds__extract_month - , subq_39.listing__ds__extract_day - , subq_39.listing__ds__extract_dow - , subq_39.listing__ds__extract_doy - , subq_39.listing__created_at__day - , subq_39.listing__created_at__week - , subq_39.listing__created_at__month - , subq_39.listing__created_at__quarter - , subq_39.listing__created_at__year - , subq_39.listing__created_at__extract_year - , subq_39.listing__created_at__extract_quarter - , subq_39.listing__created_at__extract_month - , subq_39.listing__created_at__extract_day - , subq_39.listing__created_at__extract_dow - , subq_39.listing__created_at__extract_doy - , subq_39.ds__day AS metric_time__day - , subq_39.ds__week AS metric_time__week - , subq_39.ds__month AS metric_time__month - , subq_39.ds__quarter AS metric_time__quarter - , subq_39.ds__year AS metric_time__year - , subq_39.ds__extract_year AS metric_time__extract_year - , subq_39.ds__extract_quarter AS metric_time__extract_quarter - , subq_39.ds__extract_month AS metric_time__extract_month - , subq_39.ds__extract_day AS metric_time__extract_day - , subq_39.ds__extract_dow AS metric_time__extract_dow - , subq_39.ds__extract_doy AS metric_time__extract_doy - , subq_39.listing - , subq_39.user - , subq_39.listing__user - , subq_39.country_latest - , subq_39.is_lux_latest - , subq_39.capacity_latest - , subq_39.listing__country_latest - , subq_39.listing__is_lux_latest - , subq_39.listing__capacity_latest - , subq_39.listings - , subq_39.largest_listing - , subq_39.smallest_listing - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_39 - ) subq_40 - ) subq_41 - ON - subq_38.listing = subq_41.listing - ) subq_42 - ) subq_43 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_32 + ) subq_33 + ) subq_34 + ON + subq_31.listing = subq_34.listing + ) subq_35 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') - ) subq_44 - ) subq_45 + ) subq_36 + ) subq_37 GROUP BY - subq_45.listing__capacity_latest - ) subq_46 - ) subq_47 + subq_37.listing__capacity_latest + ) subq_38 + ) subq_39 ON - subq_35.listing__capacity_latest = subq_47.listing__capacity_latest + subq_29.listing__capacity_latest = subq_39.listing__capacity_latest GROUP BY - COALESCE(subq_35.listing__capacity_latest, subq_47.listing__capacity_latest) - ) subq_48 -) subq_49 + COALESCE(subq_29.listing__capacity_latest, subq_39.listing__capacity_latest) + ) subq_40 +) subq_41 ON - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest) = subq_49.listing__capacity_latest + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest) = subq_41.listing__capacity_latest GROUP BY - COALESCE(subq_11.listing__capacity_latest, subq_23.listing__capacity_latest, subq_49.listing__capacity_latest) + COALESCE(subq_9.listing__capacity_latest, subq_19.listing__capacity_latest, subq_41.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql index 2ca354329c..9985ab9657 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_saved_query_with_metric_joins_and_filter__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Combine Aggregated Outputs SELECT - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_61.bookings) AS bookings - , MAX(subq_73.views) AS views - , MAX(CAST(subq_98.bookings AS DOUBLE) / CAST(NULLIF(subq_98.views, 0) AS DOUBLE)) AS bookings_per_view + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_51.bookings) AS bookings + , MAX(subq_61.views) AS views + , MAX(CAST(subq_82.bookings AS DOUBLE) / CAST(NULLIF(subq_82.views, 0) AS DOUBLE)) AS bookings_per_view FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -14,31 +14,29 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_52.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_52.bookings AS bookings + , subq_43.metric_time__day AS metric_time__day + , subq_43.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_52 + ) subq_43 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_52.listing = listings_latest_src_28000.listing_id - ) subq_57 + subq_43.listing = listings_latest_src_28000.listing_id + ) subq_47 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_61 +) subq_51 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -49,39 +47,37 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_64.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_64.views AS views + , subq_53.metric_time__day AS metric_time__day + , subq_53.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_64 + ) subq_53 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_64.listing = listings_latest_src_28000.listing_id - ) subq_69 + subq_53.listing = listings_latest_src_28000.listing_id + ) subq_57 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest -) subq_73 +) subq_61 ON - subq_61.listing__capacity_latest = subq_73.listing__capacity_latest + subq_51.listing__capacity_latest = subq_61.listing__capacity_latest FULL OUTER JOIN ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) AS listing__capacity_latest - , MAX(subq_85.bookings) AS bookings - , MAX(subq_97.views) AS views + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) AS listing__capacity_latest + , MAX(subq_71.bookings) AS bookings + , MAX(subq_81.views) AS views FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__capacity_latest'] @@ -92,31 +88,29 @@ FULL OUTER JOIN ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_76.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_76.bookings AS bookings + , subq_63.metric_time__day AS metric_time__day + , subq_63.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_76 + ) subq_63 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_76.listing = listings_latest_src_28000.listing_id - ) subq_81 + subq_63.listing = listings_latest_src_28000.listing_id + ) subq_67 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_85 + ) subq_71 FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['views', 'listing__capacity_latest'] @@ -127,37 +121,35 @@ FULL OUTER JOIN ( , SUM(views) AS views FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_88.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest + listings_latest_src_28000.is_lux AS listing__is_lux_latest , listings_latest_src_28000.capacity AS listing__capacity_latest - , subq_88.views AS views + , subq_73.metric_time__day AS metric_time__day + , subq_73.views AS views FROM ( -- Read Elements From Semantic Model 'views_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['views', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_28000 - ) subq_88 + ) subq_73 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_88.listing = listings_latest_src_28000.listing_id - ) subq_93 + subq_73.listing = listings_latest_src_28000.listing_id + ) subq_77 WHERE (listing__is_lux_latest) AND (metric_time__day >= '2020-01-02') GROUP BY listing__capacity_latest - ) subq_97 + ) subq_81 ON - subq_85.listing__capacity_latest = subq_97.listing__capacity_latest + subq_71.listing__capacity_latest = subq_81.listing__capacity_latest GROUP BY - COALESCE(subq_85.listing__capacity_latest, subq_97.listing__capacity_latest) -) subq_98 + COALESCE(subq_71.listing__capacity_latest, subq_81.listing__capacity_latest) +) subq_82 ON - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest) = subq_98.listing__capacity_latest + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest) = subq_82.listing__capacity_latest GROUP BY - COALESCE(subq_61.listing__capacity_latest, subq_73.listing__capacity_latest, subq_98.listing__capacity_latest) + COALESCE(subq_51.listing__capacity_latest, subq_61.listing__capacity_latest, subq_82.listing__capacity_latest) diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index f16d7296b5..632be9a929 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 6e8a46fe3b..8892599ad9 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -13,6 +13,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -21,13 +22,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql index 9910ef6159..b8bd86bf20 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql index 31b5d1e8d5..364f112122 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_single_categorical_dimension_pushdown__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0.sql index 13bfe67ed2..7389578001 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0.sql @@ -1,387 +1,563 @@ -- Compute Metrics via Expressions SELECT - subq_10.listing__country_latest - , subq_10.bookings + subq_8.listing__country_latest + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.listing__country_latest - , SUM(subq_9.bookings) AS bookings + subq_7.listing__country_latest + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'listing__country_latest'] SELECT - subq_8.listing__country_latest - , subq_8.bookings + subq_6.listing__country_latest + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.listing__is_lux_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.listing__is_lux_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE booking__is_instant OR listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.listing__country_latest -) subq_10 + subq_7.listing__country_latest +) subq_8 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0_optimized.sql index be31b01767..307eb5e373 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_skipped_pushdown__plan0_optimized.sql @@ -7,27 +7,25 @@ SELECT , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'listing__is_lux_latest'] SELECT - subq_13.booking__is_instant AS booking__is_instant - , listings_latest_src_28000.country AS listing__country_latest + listings_latest_src_28000.country AS listing__country_latest , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_13.bookings AS bookings + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE booking__is_instant OR listing__is_lux_latest GROUP BY listing__country_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql index 15d05a41a4..a2257be72a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY booking__is_instant -) subq_10 +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql index fb3160b25d..1f859837dd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - listings_src_26000.active_from AS window_start__day - , DATETIME_TRUNC(listings_src_26000.active_from, isoweek) AS window_start__week - , DATETIME_TRUNC(listings_src_26000.active_from, month) AS window_start__month - , DATETIME_TRUNC(listings_src_26000.active_from, quarter) AS window_start__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_src_26000.active_to, isoweek) AS window_end__week - , DATETIME_TRUNC(listings_src_26000.active_to, month) AS window_end__month - , DATETIME_TRUNC(listings_src_26000.active_to, quarter) AS window_end__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_src_26000.active_from, isoweek) AS listing__window_start__week - , DATETIME_TRUNC(listings_src_26000.active_from, month) AS listing__window_start__month - , DATETIME_TRUNC(listings_src_26000.active_from, quarter) AS listing__window_start__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_src_26000.active_to, isoweek) AS listing__window_end__week - , DATETIME_TRUNC(listings_src_26000.active_to, month) AS listing__window_end__month - , DATETIME_TRUNC(listings_src_26000.active_to, quarter) AS listing__window_end__quarter - , DATETIME_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_3 - ) subq_4 - ON + listings_src_26000.active_from AS window_start__day + , DATETIME_TRUNC(listings_src_26000.active_from, isoweek) AS window_start__week + , DATETIME_TRUNC(listings_src_26000.active_from, month) AS window_start__month + , DATETIME_TRUNC(listings_src_26000.active_from, quarter) AS window_start__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_src_26000.active_to, isoweek) AS window_end__week + , DATETIME_TRUNC(listings_src_26000.active_to, month) AS window_end__month + , DATETIME_TRUNC(listings_src_26000.active_to, quarter) AS window_end__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_src_26000.active_from, isoweek) AS listing__window_start__week + , DATETIME_TRUNC(listings_src_26000.active_from, month) AS listing__window_start__month + , DATETIME_TRUNC(listings_src_26000.active_from, quarter) AS listing__window_start__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_src_26000.active_to, isoweek) AS listing__window_end__week + , DATETIME_TRUNC(listings_src_26000.active_to, month) AS listing__window_end__month + , DATETIME_TRUNC(listings_src_26000.active_to, quarter) AS listing__window_end__quarter + , DATETIME_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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY metric_time__day -) subq_9 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql index 6e165cd829..693d2bee4c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql index 6fe39bd079..c05c1c20a4 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_28000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day - , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week - , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month - , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter - , DATETIME_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_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS created_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__ds__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__ds__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__ds__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(listings_latest_src_28000.created_at, day) AS listing__created_at__day + , DATETIME_TRUNC(listings_latest_src_28000.created_at, isoweek) AS listing__created_at__week + , DATETIME_TRUNC(listings_latest_src_28000.created_at, month) AS listing__created_at__month + , DATETIME_TRUNC(listings_latest_src_28000.created_at, quarter) AS listing__created_at__quarter + , DATETIME_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_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY metric_time__day - ) subq_22 - ) subq_23 + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY metric_time__day - ) subq_27 - ) subq_28 + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.metric_time__day GROUP BY metric_time__day -) subq_29 +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql index 079fc206eb..c2e0dc76e2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY metric_time__day -) subq_47 +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql index 813a04508b..d8bb800366 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 - ) subq_6 + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY metric_time__day - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY metric_time__day -) subq_12 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql index efac34f0c1..83d3a37922 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY metric_time__day - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY metric_time__day -) subq_25 +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 39ccdf1d7f..42b85c8d5f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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 NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 -) subq_6 + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 13fca71a38..5364fd7e52 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql index ccb19f439d..99304d85d6 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY metric_time__day , listing__user__home_state_latest -) subq_10 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 84ba528526..59092a36c5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,18 +28,18 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql index c20a671fd7..ed01d37bd3 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow - , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATETIME_TRUNC(bookings_source_src_26000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_26000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_26000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_26000.ds, quarter) AS booking__ds__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds, year) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds) - 1) AS booking__ds__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_TRUNC(bookings_source_src_26000.ds_partitioned, year) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.ds_partitioned) - 1) AS booking__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_TRUNC(bookings_source_src_26000.paid_at, year) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , IF(EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) = 1, 7, EXTRACT(dayofweek FROM bookings_source_src_26000.paid_at) - 1) AS booking__paid_at__extract_dow + , EXTRACT(dayofyear FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY metric_time__day , listing__lux_listing__is_confirmed_lux -) subq_10 +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql index b3653bd063..689c55c454 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,18 +28,18 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql index d4181dd14d..e6a233bf87 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS ds__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS ds__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS account_id__ds__day - , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS account_id__ds__week - , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS account_id__ds__month - , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS account_id__ds__quarter - , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS account_id__ds__extract_dow - , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS ds__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS ds__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) AS account_id__ds_partitioned__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, isoweek) AS account_id__ds_partitioned__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, month) AS account_id__ds_partitioned__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, year) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds_partitioned) - 1) AS account_id__ds_partitioned__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATETIME_TRUNC(account_month_txns_src_22000.ds, day) AS account_id__ds__day + , DATETIME_TRUNC(account_month_txns_src_22000.ds, isoweek) AS account_id__ds__week + , DATETIME_TRUNC(account_month_txns_src_22000.ds, month) AS account_id__ds__month + , DATETIME_TRUNC(account_month_txns_src_22000.ds, quarter) AS account_id__ds__quarter + , DATETIME_TRUNC(account_month_txns_src_22000.ds, year) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , IF(EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) = 1, 7, EXTRACT(dayofweek FROM account_month_txns_src_22000.ds) - 1) AS account_id__ds__extract_dow + , EXTRACT(dayofyear FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(dayofyear FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY account_id__customer_id__customer_name -) subq_12 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql index 6effa4e774..36f8701526 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATETIME_TRUNC(bridge_table_src_22000.ds_partitioned, day) = DATETIME_TRUNC(customer_table_src_22000.ds_partitioned, day) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_22.ds_partitioned__day + DATETIME_TRUNC(account_month_txns_src_22000.ds_partitioned, day) = subq_20.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0.sql index bf796aec43..473adf9d42 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATETIME_TRUNC(accounts_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(accounts_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(accounts_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(accounts_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_TRUNC(accounts_source_src_28000.ds, year) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , IF(EXTRACT(dayofweek FROM accounts_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM accounts_source_src_28000.ds) - 1) AS ds__extract_dow + , EXTRACT(dayofyear FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, month) AS ds_month__month + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, quarter) AS ds_month__quarter + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, year) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATETIME_TRUNC(accounts_source_src_28000.ds, day) AS account__ds__day + , DATETIME_TRUNC(accounts_source_src_28000.ds, isoweek) AS account__ds__week + , DATETIME_TRUNC(accounts_source_src_28000.ds, month) AS account__ds__month + , DATETIME_TRUNC(accounts_source_src_28000.ds, quarter) AS account__ds__quarter + , DATETIME_TRUNC(accounts_source_src_28000.ds, year) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , IF(EXTRACT(dayofweek FROM accounts_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM accounts_source_src_28000.ds) - 1) AS account__ds__extract_dow + , EXTRACT(dayofyear FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, month) AS account__ds_month__month + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, quarter) AS account__ds_month__quarter + , DATETIME_TRUNC(accounts_source_src_28000.ds_month, year) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATETIME_TRUNC(accounts_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(accounts_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(accounts_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(accounts_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_TRUNC(accounts_source_src_28000.ds, year) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , IF(EXTRACT(dayofweek FROM accounts_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM accounts_source_src_28000.ds) - 1) AS ds__extract_dow - , EXTRACT(dayofyear FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, month) AS ds_month__month - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, quarter) AS ds_month__quarter - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, year) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATETIME_TRUNC(accounts_source_src_28000.ds, day) AS account__ds__day - , DATETIME_TRUNC(accounts_source_src_28000.ds, isoweek) AS account__ds__week - , DATETIME_TRUNC(accounts_source_src_28000.ds, month) AS account__ds__month - , DATETIME_TRUNC(accounts_source_src_28000.ds, quarter) AS account__ds__quarter - , DATETIME_TRUNC(accounts_source_src_28000.ds, year) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , IF(EXTRACT(dayofweek FROM accounts_source_src_28000.ds) = 1, 7, EXTRACT(dayofweek FROM accounts_source_src_28000.ds) - 1) AS account__ds__extract_dow - , EXTRACT(dayofyear FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, month) AS account__ds_month__month - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, quarter) AS account__ds_month__quarter - , DATETIME_TRUNC(accounts_source_src_28000.ds_month, year) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 97055bf54c..2691f061d3 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATETIME_TRUNC(ds_month, month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATETIME_TRUNC(ds_month, month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql index f0b7a55606..ff47159240 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , DATETIME_TRUNC(id_verifications_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(id_verifications_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(id_verifications_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(id_verifications_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(id_verifications_src_28000.ds, day) AS verification__ds__day - , DATETIME_TRUNC(id_verifications_src_28000.ds, isoweek) AS verification__ds__week - , DATETIME_TRUNC(id_verifications_src_28000.ds, month) AS verification__ds__month - , DATETIME_TRUNC(id_verifications_src_28000.ds, quarter) AS verification__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS verification__ds_partitioned__day - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS verification__ds_partitioned__week - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS verification__ds_partitioned__month - , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS verification__ds_partitioned__quarter - , DATETIME_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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , DATETIME_TRUNC(id_verifications_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(id_verifications_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(id_verifications_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(id_verifications_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(id_verifications_src_28000.ds, day) AS verification__ds__day + , DATETIME_TRUNC(id_verifications_src_28000.ds, isoweek) AS verification__ds__week + , DATETIME_TRUNC(id_verifications_src_28000.ds, month) AS verification__ds__month + , DATETIME_TRUNC(id_verifications_src_28000.ds, quarter) AS verification__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, day) AS verification__ds_partitioned__day + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, isoweek) AS verification__ds_partitioned__week + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, month) AS verification__ds_partitioned__month + , DATETIME_TRUNC(id_verifications_src_28000.ds_partitioned, quarter) AS verification__ds_partitioned__quarter + , DATETIME_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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(dayofyear FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY user__home_state -) subq_8 +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql index c74a53fa6c..b37c01d2b5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATETIME_TRUNC(ds_partitioned, day) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) + subq_9.ds_partitioned__day = DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) ) GROUP BY user__home_state diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql index d1d6bf4fc2..aa587bb6e7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_7.booking__is_instant +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql index 477d954daf..4dcc9d756e 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - 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_3 - ) subq_4 - ON + 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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_6.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql index 8f567bda9a..6b1bdca6cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql index 38d7fcc594..d3448240c2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_17.metric_time__day + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql index 3b5d6bfe50..aec1662154 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_46.metric_time__day) -) subq_47 + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql index 4f2cd9819b..b1fd197575 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a465dac6f6..a50ba5881c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 87a8c39f99..5586e72e02 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_3.metric_time__day + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 3202b9915d..abf77d4144 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql index 2f03037fef..b54e3d2ac8 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 43c459ada2..c693b5ecd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_11.metric_time__day + , subq_16.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql index 709e0720a8..085266baf2 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql index d0d6125e14..147c41636f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_11.metric_time__day + , subq_16.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql index a5a7d0a80c..efb88a46f6 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.account_id__customer_id__customer_name -) subq_12 + subq_10.account_id__customer_id__customer_name +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql index 13473156ca..d59e00bb74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_20.ds_partitioned__day ) GROUP BY - subq_22.customer_id__customer_name + subq_20.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0.sql index 308afbf3dd..7945f0a2c1 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM accounts_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM accounts_source_src_28000.ds) AS account__ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM accounts_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM accounts_source_src_28000.ds) AS account__ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 90b981493f..93ae8752df 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATE_TRUNC('month', ds_month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATE_TRUNC('month', ds_month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql index f4e2ab7a3d..8ca20862af 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , 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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , 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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.user__home_state -) subq_8 + subq_6.user__home_state +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql index be2da473cc..abeac83bb7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) + subq_9.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY users_ds_source_src_28000.home_state diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql index 1305901493..88104eab74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_7.booking__is_instant +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql index 388adce3a5..fc8d027636 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - 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_3 - ) subq_4 - ON + 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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_6.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql index 8f567bda9a..6b1bdca6cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql index d37eadd7ca..d01048c17c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_17.metric_time__day + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql index 3b5d6bfe50..aec1662154 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_46.metric_time__day) -) subq_47 + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql index 19a913bb1f..02e5a8a4bd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql index e3a93f4824..aeff29ca51 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 9182b35971..85ce7fc8b5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_3.metric_time__day + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 3202b9915d..abf77d4144 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql index 23e1270946..281be2468a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 43c459ada2..c693b5ecd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_11.metric_time__day + , subq_16.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql index fd5244631f..d118c9bb67 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql index d0d6125e14..147c41636f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_11.metric_time__day + , subq_16.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql index 457fb2d259..c896c871a6 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(isodow FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.account_id__customer_id__customer_name -) subq_12 + subq_10.account_id__customer_id__customer_name +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql index 13473156ca..d59e00bb74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_20.ds_partitioned__day ) GROUP BY - subq_22.customer_id__customer_name + subq_20.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0.sql index c4eac70b4c..a4d876462a 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM accounts_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , EXTRACT(isodow FROM accounts_source_src_28000.ds) AS account__ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM accounts_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , EXTRACT(isodow FROM accounts_source_src_28000.ds) AS account__ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 90b981493f..93ae8752df 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATE_TRUNC('month', ds_month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATE_TRUNC('month', ds_month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql index c1a2b4b8f9..d809f2c981 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , 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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , 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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.user__home_state -) subq_8 + subq_6.user__home_state +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql index be2da473cc..abeac83bb7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) + subq_9.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY users_ds_source_src_28000.home_state diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql index c4b0570d6b..8503dd36b4 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_7.booking__is_instant +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql index e255b7e61a..6f43d560af 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - 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_3 - ) subq_4 - ON + 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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_6.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql index 8f567bda9a..6b1bdca6cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql index 5449922a0f..985f295abd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , CASE WHEN EXTRACT(dow FROM listings_latest_src_28000.created_at) = 0 THEN EXTRACT(dow FROM listings_latest_src_28000.created_at) + 7 ELSE EXTRACT(dow FROM listings_latest_src_28000.created_at) END AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_17.metric_time__day + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql index 3b5d6bfe50..aec1662154 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_46.metric_time__day) -) subq_47 + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql index cda95b14fc..5a8ae33b2e 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql index e3a93f4824..aeff29ca51 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 6b26ce724b..a92913a520 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_3.metric_time__day + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 3202b9915d..abf77d4144 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql index 5ee49254f6..efd5344173 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 43c459ada2..c693b5ecd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_11.metric_time__day + , subq_16.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql index 6b1ccfeece..68465c9d2d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_26000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_26000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql index d0d6125e14..147c41636f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_11.metric_time__day + , subq_16.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql index 273a4e3fb8..d31fad05e4 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds_partitioned) END AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , CASE WHEN EXTRACT(dow FROM account_month_txns_src_22000.ds) = 0 THEN EXTRACT(dow FROM account_month_txns_src_22000.ds) + 7 ELSE EXTRACT(dow FROM account_month_txns_src_22000.ds) END AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.account_id__customer_id__customer_name -) subq_12 + subq_10.account_id__customer_id__customer_name +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql index 13473156ca..d59e00bb74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_20.ds_partitioned__day ) GROUP BY - subq_22.customer_id__customer_name + subq_20.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0.sql index df5d0dfc59..46225cb9fd 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM accounts_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM accounts_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM accounts_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , CASE WHEN EXTRACT(dow FROM accounts_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM accounts_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM accounts_source_src_28000.ds) END AS account__ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM accounts_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM accounts_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM accounts_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , CASE WHEN EXTRACT(dow FROM accounts_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM accounts_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM accounts_source_src_28000.ds) END AS account__ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 90b981493f..93ae8752df 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATE_TRUNC('month', ds_month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATE_TRUNC('month', ds_month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql index dd730927f9..f27dc01000 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , 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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , 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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.user__home_state -) subq_8 + subq_6.user__home_state +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql index be2da473cc..abeac83bb7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) + subq_9.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY users_ds_source_src_28000.home_state diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql index 2124d8bd4a..f59931caab 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_7.booking__is_instant +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql index 4c40cd5bc6..68c1d64b27 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - 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_3 - ) subq_4 - ON + 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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_6.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql index 8f567bda9a..6b1bdca6cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql index 702c58a9bc..b00468f676 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(dayofweekiso FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_17.metric_time__day + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql index 3b5d6bfe50..aec1662154 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_46.metric_time__day) -) subq_47 + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql index 09af3a3c27..5677da6ab7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a465dac6f6..a50ba5881c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql index 73954cba02..7accc463c8 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_3.metric_time__day + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 3202b9915d..abf77d4144 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql index b2184830a3..ab38eb8f26 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 43c459ada2..c693b5ecd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_11.metric_time__day + , subq_16.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql index 5203fc30b0..3556646016 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql index d0d6125e14..147c41636f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_11.metric_time__day + , subq_16.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql index bae9c0e022..4a970db926 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(dayofweekiso FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.account_id__customer_id__customer_name -) subq_12 + subq_10.account_id__customer_id__customer_name +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql index 13473156ca..d59e00bb74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_20.ds_partitioned__day ) GROUP BY - subq_22.customer_id__customer_name + subq_20.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0.sql index bc4617368b..8dbc4b8c6e 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM accounts_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , EXTRACT(dayofweekiso FROM accounts_source_src_28000.ds) AS account__ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM accounts_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , EXTRACT(dayofweekiso FROM accounts_source_src_28000.ds) AS account__ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 90b981493f..93ae8752df 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATE_TRUNC('month', ds_month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATE_TRUNC('month', ds_month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql index 3e25438f88..0912a2ed57 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , 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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , 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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.user__home_state -) subq_8 + subq_6.user__home_state +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql index be2da473cc..abeac83bb7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) + subq_9.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY users_ds_source_src_28000.home_state diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql index 29a44f49a4..68939aa2a7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -1,383 +1,560 @@ -- Compute Metrics via Expressions SELECT - subq_10.booking__is_instant - , subq_10.bookings + subq_8.booking__is_instant + , subq_8.bookings FROM ( -- Aggregate Measures SELECT - subq_9.booking__is_instant - , SUM(subq_9.bookings) AS bookings + subq_7.booking__is_instant + , SUM(subq_7.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant'] SELECT - subq_8.booking__is_instant - , subq_8.bookings + subq_6.booking__is_instant + , subq_6.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_7.booking__is_instant - , subq_7.listing__country_latest - , subq_7.bookings + subq_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__country_latest + , 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 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing__country_latest'] + -- Join Standard Outputs SELECT - subq_6.booking__is_instant - , subq_6.listing__country_latest - , subq_6.bookings + subq_4.country_latest AS listing__country_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.country_latest AS listing__country_latest - , subq_2.listing AS listing - , subq_2.booking__is_instant AS booking__is_instant - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.listing - , subq_1.booking__is_instant - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['country_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['country_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.country_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.country_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__country_latest = 'us' - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.booking__is_instant -) subq_10 + subq_7.booking__is_instant +) subq_8 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql index 9a9173fe96..b471f38fed 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_filter_with_where_constraint_on_join_dim__plan0_optimized.sql @@ -7,26 +7,24 @@ SELECT , SUM(bookings) AS bookings 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_28000.country AS listing__country_latest - , subq_13.bookings AS bookings + listings_latest_src_28000.country AS listing__country_latest + , subq_10.booking__is_instant AS booking__is_instant + , subq_10.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'listing'] SELECT listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_13 + ) subq_10 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_13.listing = listings_latest_src_28000.listing_id -) subq_18 + subq_10.listing = listings_latest_src_28000.listing_id +) subq_14 WHERE listing__country_latest = 'us' GROUP BY booking__is_instant diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql index 6e92a52050..1b6bc2717d 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0.sql @@ -1,313 +1,480 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.bookings AS family_bookings + subq_7.metric_time__day + , subq_7.bookings AS family_bookings FROM ( -- Aggregate Measures SELECT - subq_8.metric_time__day - , SUM(subq_8.bookings) AS bookings + subq_6.metric_time__day + , SUM(subq_6.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_7.metric_time__day - , subq_7.bookings + subq_5.metric_time__day + , subq_5.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_6.metric_time__day - , subq_6.listing__capacity - , subq_6.bookings + subq_4.ds__day + , subq_4.ds__week + , subq_4.ds__month + , subq_4.ds__quarter + , subq_4.ds__year + , subq_4.ds__extract_year + , subq_4.ds__extract_quarter + , subq_4.ds__extract_month + , subq_4.ds__extract_day + , subq_4.ds__extract_dow + , subq_4.ds__extract_doy + , subq_4.ds_partitioned__day + , subq_4.ds_partitioned__week + , subq_4.ds_partitioned__month + , subq_4.ds_partitioned__quarter + , subq_4.ds_partitioned__year + , subq_4.ds_partitioned__extract_year + , subq_4.ds_partitioned__extract_quarter + , subq_4.ds_partitioned__extract_month + , subq_4.ds_partitioned__extract_day + , subq_4.ds_partitioned__extract_dow + , subq_4.ds_partitioned__extract_doy + , subq_4.paid_at__day + , subq_4.paid_at__week + , subq_4.paid_at__month + , subq_4.paid_at__quarter + , subq_4.paid_at__year + , subq_4.paid_at__extract_year + , subq_4.paid_at__extract_quarter + , subq_4.paid_at__extract_month + , subq_4.paid_at__extract_day + , subq_4.paid_at__extract_dow + , subq_4.paid_at__extract_doy + , subq_4.booking__ds__day + , subq_4.booking__ds__week + , subq_4.booking__ds__month + , subq_4.booking__ds__quarter + , subq_4.booking__ds__year + , subq_4.booking__ds__extract_year + , subq_4.booking__ds__extract_quarter + , subq_4.booking__ds__extract_month + , subq_4.booking__ds__extract_day + , subq_4.booking__ds__extract_dow + , subq_4.booking__ds__extract_doy + , subq_4.booking__ds_partitioned__day + , subq_4.booking__ds_partitioned__week + , subq_4.booking__ds_partitioned__month + , subq_4.booking__ds_partitioned__quarter + , subq_4.booking__ds_partitioned__year + , subq_4.booking__ds_partitioned__extract_year + , subq_4.booking__ds_partitioned__extract_quarter + , subq_4.booking__ds_partitioned__extract_month + , subq_4.booking__ds_partitioned__extract_day + , subq_4.booking__ds_partitioned__extract_dow + , subq_4.booking__ds_partitioned__extract_doy + , subq_4.booking__paid_at__day + , subq_4.booking__paid_at__week + , subq_4.booking__paid_at__month + , subq_4.booking__paid_at__quarter + , subq_4.booking__paid_at__year + , subq_4.booking__paid_at__extract_year + , subq_4.booking__paid_at__extract_quarter + , subq_4.booking__paid_at__extract_month + , subq_4.booking__paid_at__extract_day + , subq_4.booking__paid_at__extract_dow + , subq_4.booking__paid_at__extract_doy + , subq_4.metric_time__day + , subq_4.metric_time__week + , subq_4.metric_time__month + , subq_4.metric_time__quarter + , subq_4.metric_time__year + , subq_4.metric_time__extract_year + , subq_4.metric_time__extract_quarter + , subq_4.metric_time__extract_month + , subq_4.metric_time__extract_day + , subq_4.metric_time__extract_dow + , subq_4.metric_time__extract_doy + , subq_4.listing__window_start__day + , subq_4.listing__window_end__day + , subq_4.listing + , subq_4.guest + , subq_4.host + , subq_4.user + , subq_4.booking__listing + , subq_4.booking__guest + , subq_4.booking__host + , subq_4.booking__user + , subq_4.is_instant + , subq_4.booking__is_instant + , subq_4.listing__capacity + , subq_4.bookings + , subq_4.instant_bookings + , subq_4.booking_value + , subq_4.bookers + , subq_4.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'listing__capacity', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_5.metric_time__day - , subq_5.listing__capacity - , subq_5.bookings + subq_3.capacity AS listing__capacity + , subq_3.window_start__day AS listing__window_start__day + , subq_3.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_4.capacity AS listing__capacity - , subq_4.window_start__day AS listing__window_start__day - , subq_4.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['capacity', 'window_start__day', 'window_end__day', 'listing'] + SELECT + subq_2.window_start__day + , subq_2.window_end__day + , subq_2.listing + , subq_2.capacity + FROM ( + -- Read Elements From Semantic Model 'listings' SELECT - subq_3.window_start__day - , subq_3.window_end__day - , subq_3.listing - , subq_3.capacity - FROM ( - -- Read Elements From Semantic Model 'listings' - SELECT - 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_3 - ) subq_4 - ON + 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_2 + ) subq_3 + ON + ( + subq_1.listing = subq_3.listing + ) AND ( ( - subq_2.listing = subq_4.listing + subq_1.metric_time__day >= subq_3.window_start__day ) AND ( ( - subq_2.metric_time__day >= subq_4.window_start__day - ) AND ( - ( - subq_2.metric_time__day < subq_4.window_end__day - ) OR ( - subq_4.window_end__day IS NULL - ) + subq_1.metric_time__day < subq_3.window_end__day + ) OR ( + subq_3.window_end__day IS NULL ) ) - ) subq_5 - ) subq_6 + ) + ) subq_4 WHERE listing__capacity > 2 - ) subq_7 - ) subq_8 + ) subq_5 + ) subq_6 GROUP BY - subq_8.metric_time__day -) subq_9 + subq_6.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql index 8f567bda9a..6b1bdca6cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_join_to_scd_dimension__plan0_optimized.sql @@ -7,38 +7,36 @@ SELECT , SUM(bookings) AS family_bookings 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_26000.capacity AS listing__capacity - , subq_12.bookings AS bookings + listings_src_26000.capacity AS listing__capacity + , subq_9.metric_time__day AS metric_time__day + , subq_9.bookings AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 - ) subq_12 + ) subq_9 LEFT OUTER JOIN ***************************.dim_listings listings_src_26000 ON ( - subq_12.listing = listings_src_26000.listing_id + subq_9.listing = listings_src_26000.listing_id ) AND ( ( - subq_12.metric_time__day >= listings_src_26000.active_from + subq_9.metric_time__day >= listings_src_26000.active_from ) AND ( ( - subq_12.metric_time__day < listings_src_26000.active_to + subq_9.metric_time__day < listings_src_26000.active_to ) OR ( listings_src_26000.active_to IS NULL ) ) ) -) subq_16 +) subq_12 WHERE listing__capacity > 2 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql index 5f50cba6f2..7e2198b152 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0.sql @@ -1,902 +1,1256 @@ -- Compute Metrics via Expressions SELECT - subq_29.metric_time__day + subq_25.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_9.average_booking_value) AS average_booking_value + , MAX(subq_19.bookings) AS bookings + , MAX(subq_24.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.average_booking_value + subq_8.metric_time__day + , subq_8.average_booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , AVG(subq_9.average_booking_value) AS average_booking_value + subq_7.metric_time__day + , AVG(subq_7.average_booking_value) AS average_booking_value FROM ( -- Pass Only Elements: ['average_booking_value', 'metric_time__day'] SELECT - subq_8.metric_time__day - , subq_8.average_booking_value + subq_6.metric_time__day + , subq_6.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_5.ds__day + , subq_5.ds__week + , subq_5.ds__month + , subq_5.ds__quarter + , subq_5.ds__year + , subq_5.ds__extract_year + , subq_5.ds__extract_quarter + , subq_5.ds__extract_month + , subq_5.ds__extract_day + , subq_5.ds__extract_dow + , subq_5.ds__extract_doy + , subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.paid_at__day + , subq_5.paid_at__week + , subq_5.paid_at__month + , subq_5.paid_at__quarter + , subq_5.paid_at__year + , subq_5.paid_at__extract_year + , subq_5.paid_at__extract_quarter + , subq_5.paid_at__extract_month + , subq_5.paid_at__extract_day + , subq_5.paid_at__extract_dow + , subq_5.paid_at__extract_doy + , subq_5.booking__ds__day + , subq_5.booking__ds__week + , subq_5.booking__ds__month + , subq_5.booking__ds__quarter + , subq_5.booking__ds__year + , subq_5.booking__ds__extract_year + , subq_5.booking__ds__extract_quarter + , subq_5.booking__ds__extract_month + , subq_5.booking__ds__extract_day + , subq_5.booking__ds__extract_dow + , subq_5.booking__ds__extract_doy + , subq_5.booking__ds_partitioned__day + , subq_5.booking__ds_partitioned__week + , subq_5.booking__ds_partitioned__month + , subq_5.booking__ds_partitioned__quarter + , subq_5.booking__ds_partitioned__year + , subq_5.booking__ds_partitioned__extract_year + , subq_5.booking__ds_partitioned__extract_quarter + , subq_5.booking__ds_partitioned__extract_month + , subq_5.booking__ds_partitioned__extract_day + , subq_5.booking__ds_partitioned__extract_dow + , subq_5.booking__ds_partitioned__extract_doy + , subq_5.booking__paid_at__day + , subq_5.booking__paid_at__week + , subq_5.booking__paid_at__month + , subq_5.booking__paid_at__quarter + , subq_5.booking__paid_at__year + , subq_5.booking__paid_at__extract_year + , subq_5.booking__paid_at__extract_quarter + , subq_5.booking__paid_at__extract_month + , subq_5.booking__paid_at__extract_day + , subq_5.booking__paid_at__extract_dow + , subq_5.booking__paid_at__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.listing + , subq_5.guest + , subq_5.host + , subq_5.booking__listing + , subq_5.booking__guest + , subq_5.booking__host + , subq_5.is_instant + , subq_5.booking__is_instant + , subq_5.listing__is_lux_latest + , 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 FROM ( - -- Pass Only Elements: ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_6.metric_time__day - , subq_6.listing__is_lux_latest - , subq_6.average_booking_value + subq_4.is_lux_latest AS listing__is_lux_latest + , 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__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 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_5.is_lux_latest AS listing__is_lux_latest - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.average_booking_value AS average_booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['average_booking_value', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_3.listing + , subq_3.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_4.listing - , subq_4.is_lux_latest + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.listing__ds__day + , subq_2.listing__ds__week + , subq_2.listing__ds__month + , subq_2.listing__ds__quarter + , subq_2.listing__ds__year + , subq_2.listing__ds__extract_year + , subq_2.listing__ds__extract_quarter + , subq_2.listing__ds__extract_month + , subq_2.listing__ds__extract_day + , subq_2.listing__ds__extract_dow + , subq_2.listing__ds__extract_doy + , subq_2.listing__created_at__day + , subq_2.listing__created_at__week + , subq_2.listing__created_at__month + , subq_2.listing__created_at__quarter + , subq_2.listing__created_at__year + , subq_2.listing__created_at__extract_year + , subq_2.listing__created_at__extract_quarter + , subq_2.listing__created_at__extract_month + , subq_2.listing__created_at__extract_day + , subq_2.listing__created_at__extract_dow + , subq_2.listing__created_at__extract_doy + , subq_2.ds__day AS metric_time__day + , subq_2.ds__week AS metric_time__week + , subq_2.ds__month AS metric_time__month + , subq_2.ds__quarter AS metric_time__quarter + , subq_2.ds__year AS metric_time__year + , subq_2.ds__extract_year AS metric_time__extract_year + , subq_2.ds__extract_quarter AS metric_time__extract_quarter + , subq_2.ds__extract_month AS metric_time__extract_month + , subq_2.ds__extract_day AS metric_time__extract_day + , subq_2.ds__extract_dow AS metric_time__extract_dow + , subq_2.ds__extract_doy AS metric_time__extract_doy + , subq_2.listing + , subq_2.user + , subq_2.listing__user + , subq_2.country_latest + , subq_2.is_lux_latest + , subq_2.capacity_latest + , subq_2.listing__country_latest + , subq_2.listing__is_lux_latest + , subq_2.listing__capacity_latest + , subq_2.listings + , subq_2.largest_listing + , subq_2.smallest_listing FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 - ON - subq_2.listing = subq_5.listing - ) subq_6 - ) subq_7 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_2 + ) subq_3 + ) subq_4 + ON + subq_1.listing = subq_4.listing + ) subq_5 WHERE listing__is_lux_latest - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_7.metric_time__day + ) subq_8 + ) subq_9 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_22.metric_time__day - , subq_22.bookings + subq_18.metric_time__day + , subq_18.bookings FROM ( -- Aggregate Measures SELECT - subq_21.metric_time__day - , SUM(subq_21.bookings) AS bookings + subq_17.metric_time__day + , SUM(subq_17.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_20.metric_time__day - , subq_20.bookings + subq_16.metric_time__day + , subq_16.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_19.metric_time__day - , subq_19.listing__is_lux_latest - , subq_19.bookings + 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.metric_time__day + , subq_15.metric_time__week + , subq_15.metric_time__month + , subq_15.metric_time__quarter + , subq_15.metric_time__year + , subq_15.metric_time__extract_year + , subq_15.metric_time__extract_quarter + , subq_15.metric_time__extract_month + , subq_15.metric_time__extract_day + , subq_15.metric_time__extract_dow + , subq_15.metric_time__extract_doy + , subq_15.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.listing__is_lux_latest + , 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 ( - -- Pass Only Elements: ['bookings', 'listing__is_lux_latest', 'metric_time__day'] + -- Join Standard Outputs SELECT - subq_18.metric_time__day - , subq_18.listing__is_lux_latest - , subq_18.bookings + subq_14.is_lux_latest AS listing__is_lux_latest + , subq_11.ds__day AS ds__day + , subq_11.ds__week AS ds__week + , subq_11.ds__month AS ds__month + , subq_11.ds__quarter AS ds__quarter + , subq_11.ds__year AS ds__year + , subq_11.ds__extract_year AS ds__extract_year + , subq_11.ds__extract_quarter AS ds__extract_quarter + , subq_11.ds__extract_month AS ds__extract_month + , subq_11.ds__extract_day AS ds__extract_day + , subq_11.ds__extract_dow AS ds__extract_dow + , subq_11.ds__extract_doy AS ds__extract_doy + , subq_11.ds_partitioned__day AS ds_partitioned__day + , subq_11.ds_partitioned__week AS ds_partitioned__week + , subq_11.ds_partitioned__month AS ds_partitioned__month + , subq_11.ds_partitioned__quarter AS ds_partitioned__quarter + , subq_11.ds_partitioned__year AS ds_partitioned__year + , subq_11.ds_partitioned__extract_year AS ds_partitioned__extract_year + , subq_11.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter + , subq_11.ds_partitioned__extract_month AS ds_partitioned__extract_month + , subq_11.ds_partitioned__extract_day AS ds_partitioned__extract_day + , subq_11.ds_partitioned__extract_dow AS ds_partitioned__extract_dow + , subq_11.ds_partitioned__extract_doy AS ds_partitioned__extract_doy + , subq_11.paid_at__day AS paid_at__day + , subq_11.paid_at__week AS paid_at__week + , subq_11.paid_at__month AS paid_at__month + , subq_11.paid_at__quarter AS paid_at__quarter + , subq_11.paid_at__year AS paid_at__year + , subq_11.paid_at__extract_year AS paid_at__extract_year + , subq_11.paid_at__extract_quarter AS paid_at__extract_quarter + , subq_11.paid_at__extract_month AS paid_at__extract_month + , subq_11.paid_at__extract_day AS paid_at__extract_day + , subq_11.paid_at__extract_dow AS paid_at__extract_dow + , subq_11.paid_at__extract_doy AS paid_at__extract_doy + , subq_11.booking__ds__day AS booking__ds__day + , subq_11.booking__ds__week AS booking__ds__week + , subq_11.booking__ds__month AS booking__ds__month + , subq_11.booking__ds__quarter AS booking__ds__quarter + , subq_11.booking__ds__year AS booking__ds__year + , subq_11.booking__ds__extract_year AS booking__ds__extract_year + , subq_11.booking__ds__extract_quarter AS booking__ds__extract_quarter + , subq_11.booking__ds__extract_month AS booking__ds__extract_month + , subq_11.booking__ds__extract_day AS booking__ds__extract_day + , subq_11.booking__ds__extract_dow AS booking__ds__extract_dow + , subq_11.booking__ds__extract_doy AS booking__ds__extract_doy + , subq_11.booking__ds_partitioned__day AS booking__ds_partitioned__day + , subq_11.booking__ds_partitioned__week AS booking__ds_partitioned__week + , subq_11.booking__ds_partitioned__month AS booking__ds_partitioned__month + , subq_11.booking__ds_partitioned__quarter AS booking__ds_partitioned__quarter + , subq_11.booking__ds_partitioned__year AS booking__ds_partitioned__year + , subq_11.booking__ds_partitioned__extract_year AS booking__ds_partitioned__extract_year + , subq_11.booking__ds_partitioned__extract_quarter AS booking__ds_partitioned__extract_quarter + , subq_11.booking__ds_partitioned__extract_month AS booking__ds_partitioned__extract_month + , subq_11.booking__ds_partitioned__extract_day AS booking__ds_partitioned__extract_day + , subq_11.booking__ds_partitioned__extract_dow AS booking__ds_partitioned__extract_dow + , subq_11.booking__ds_partitioned__extract_doy AS booking__ds_partitioned__extract_doy + , subq_11.booking__paid_at__day AS booking__paid_at__day + , subq_11.booking__paid_at__week AS booking__paid_at__week + , subq_11.booking__paid_at__month AS booking__paid_at__month + , subq_11.booking__paid_at__quarter AS booking__paid_at__quarter + , subq_11.booking__paid_at__year AS booking__paid_at__year + , subq_11.booking__paid_at__extract_year AS booking__paid_at__extract_year + , subq_11.booking__paid_at__extract_quarter AS booking__paid_at__extract_quarter + , subq_11.booking__paid_at__extract_month AS booking__paid_at__extract_month + , subq_11.booking__paid_at__extract_day AS booking__paid_at__extract_day + , subq_11.booking__paid_at__extract_dow AS booking__paid_at__extract_dow + , subq_11.booking__paid_at__extract_doy AS booking__paid_at__extract_doy + , subq_11.metric_time__day AS metric_time__day + , subq_11.metric_time__week AS metric_time__week + , subq_11.metric_time__month AS metric_time__month + , subq_11.metric_time__quarter AS metric_time__quarter + , subq_11.metric_time__year AS metric_time__year + , subq_11.metric_time__extract_year AS metric_time__extract_year + , subq_11.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_11.metric_time__extract_month AS metric_time__extract_month + , subq_11.metric_time__extract_day AS metric_time__extract_day + , subq_11.metric_time__extract_dow AS metric_time__extract_dow + , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_11.listing AS listing + , subq_11.guest AS guest + , subq_11.host AS host + , subq_11.booking__listing AS booking__listing + , subq_11.booking__guest AS booking__guest + , subq_11.booking__host AS booking__host + , subq_11.is_instant AS is_instant + , subq_11.booking__is_instant AS booking__is_instant + , subq_11.bookings AS bookings + , subq_11.instant_bookings AS instant_bookings + , subq_11.booking_value AS booking_value + , subq_11.max_booking_value AS max_booking_value + , subq_11.min_booking_value AS min_booking_value + , subq_11.bookers AS bookers + , subq_11.average_booking_value AS average_booking_value + , subq_11.referred_bookings AS referred_bookings + , subq_11.median_booking_value AS median_booking_value + , subq_11.booking_value_p99 AS booking_value_p99 + , subq_11.discrete_booking_value_p99 AS discrete_booking_value_p99 + , subq_11.approximate_continuous_booking_value_p99 AS approximate_continuous_booking_value_p99 + , subq_11.approximate_discrete_booking_value_p99 AS approximate_discrete_booking_value_p99 FROM ( - -- Join Standard Outputs + -- Metric Time Dimension 'ds' SELECT - subq_17.is_lux_latest AS listing__is_lux_latest - , subq_14.metric_time__day AS metric_time__day - , subq_14.listing AS listing - , subq_14.bookings AS bookings + subq_10.ds__day + , subq_10.ds__week + , subq_10.ds__month + , subq_10.ds__quarter + , subq_10.ds__year + , subq_10.ds__extract_year + , subq_10.ds__extract_quarter + , subq_10.ds__extract_month + , subq_10.ds__extract_day + , subq_10.ds__extract_dow + , subq_10.ds__extract_doy + , subq_10.ds_partitioned__day + , subq_10.ds_partitioned__week + , subq_10.ds_partitioned__month + , subq_10.ds_partitioned__quarter + , subq_10.ds_partitioned__year + , subq_10.ds_partitioned__extract_year + , subq_10.ds_partitioned__extract_quarter + , subq_10.ds_partitioned__extract_month + , subq_10.ds_partitioned__extract_day + , subq_10.ds_partitioned__extract_dow + , subq_10.ds_partitioned__extract_doy + , subq_10.paid_at__day + , subq_10.paid_at__week + , subq_10.paid_at__month + , subq_10.paid_at__quarter + , subq_10.paid_at__year + , subq_10.paid_at__extract_year + , subq_10.paid_at__extract_quarter + , subq_10.paid_at__extract_month + , subq_10.paid_at__extract_day + , subq_10.paid_at__extract_dow + , subq_10.paid_at__extract_doy + , subq_10.booking__ds__day + , subq_10.booking__ds__week + , subq_10.booking__ds__month + , subq_10.booking__ds__quarter + , subq_10.booking__ds__year + , subq_10.booking__ds__extract_year + , subq_10.booking__ds__extract_quarter + , subq_10.booking__ds__extract_month + , subq_10.booking__ds__extract_day + , subq_10.booking__ds__extract_dow + , subq_10.booking__ds__extract_doy + , subq_10.booking__ds_partitioned__day + , subq_10.booking__ds_partitioned__week + , subq_10.booking__ds_partitioned__month + , subq_10.booking__ds_partitioned__quarter + , subq_10.booking__ds_partitioned__year + , subq_10.booking__ds_partitioned__extract_year + , subq_10.booking__ds_partitioned__extract_quarter + , subq_10.booking__ds_partitioned__extract_month + , subq_10.booking__ds_partitioned__extract_day + , subq_10.booking__ds_partitioned__extract_dow + , subq_10.booking__ds_partitioned__extract_doy + , subq_10.booking__paid_at__day + , subq_10.booking__paid_at__week + , subq_10.booking__paid_at__month + , subq_10.booking__paid_at__quarter + , subq_10.booking__paid_at__year + , subq_10.booking__paid_at__extract_year + , subq_10.booking__paid_at__extract_quarter + , subq_10.booking__paid_at__extract_month + , subq_10.booking__paid_at__extract_day + , subq_10.booking__paid_at__extract_dow + , subq_10.booking__paid_at__extract_doy + , subq_10.ds__day AS metric_time__day + , subq_10.ds__week AS metric_time__week + , subq_10.ds__month AS metric_time__month + , subq_10.ds__quarter AS metric_time__quarter + , subq_10.ds__year AS metric_time__year + , subq_10.ds__extract_year AS metric_time__extract_year + , subq_10.ds__extract_quarter AS metric_time__extract_quarter + , subq_10.ds__extract_month AS metric_time__extract_month + , subq_10.ds__extract_day AS metric_time__extract_day + , subq_10.ds__extract_dow AS metric_time__extract_dow + , subq_10.ds__extract_doy AS metric_time__extract_doy + , subq_10.listing + , subq_10.guest + , subq_10.host + , subq_10.booking__listing + , subq_10.booking__guest + , subq_10.booking__host + , subq_10.is_instant + , subq_10.booking__is_instant + , subq_10.bookings + , subq_10.instant_bookings + , subq_10.booking_value + , subq_10.max_booking_value + , subq_10.min_booking_value + , subq_10.bookers + , subq_10.average_booking_value + , subq_10.referred_bookings + , subq_10.median_booking_value + , subq_10.booking_value_p99 + , subq_10.discrete_booking_value_p99 + , subq_10.approximate_continuous_booking_value_p99 + , subq_10.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_13.metric_time__day - , subq_13.listing - , subq_13.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 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 - ) subq_13 - ) subq_14 - LEFT OUTER JOIN ( - -- Pass Only Elements: ['is_lux_latest', 'listing'] + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_10 + ) subq_11 + LEFT OUTER JOIN ( + -- Pass Only Elements: ['is_lux_latest', 'listing'] + SELECT + subq_13.listing + , subq_13.is_lux_latest + FROM ( + -- Metric Time Dimension 'ds' SELECT - subq_16.listing - , subq_16.is_lux_latest + 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 ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'listings_latest' 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 - FROM ( - -- Read Elements From Semantic Model 'listings_latest' - SELECT - 1 AS listings - , listings_latest_src_28000.capacity AS largest_listing - , listings_latest_src_28000.capacity AS smallest_listing - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy - , listings_latest_src_28000.country AS country_latest - , listings_latest_src_28000.is_lux AS is_lux_latest - , listings_latest_src_28000.capacity AS capacity_latest - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy - , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day - , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week - , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month - , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter - , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year - , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year - , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter - , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month - , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow - , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy - , listings_latest_src_28000.country AS listing__country_latest - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , listings_latest_src_28000.capacity AS listing__capacity_latest - , listings_latest_src_28000.listing_id AS listing - , listings_latest_src_28000.user_id AS user - , listings_latest_src_28000.user_id AS listing__user - FROM ***************************.dim_listings_latest listings_latest_src_28000 - ) subq_15 - ) subq_16 - ) subq_17 - ON - subq_14.listing = subq_17.listing - ) subq_18 - ) subq_19 + 1 AS listings + , listings_latest_src_28000.capacity AS largest_listing + , listings_latest_src_28000.capacity AS smallest_listing + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy + , listings_latest_src_28000.country AS country_latest + , listings_latest_src_28000.is_lux AS is_lux_latest + , listings_latest_src_28000.capacity AS capacity_latest + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy + , DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day + , DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week + , DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month + , DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter + , DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year + , EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year + , EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter + , EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month + , EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow + , EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy + , listings_latest_src_28000.country AS listing__country_latest + , listings_latest_src_28000.is_lux AS listing__is_lux_latest + , listings_latest_src_28000.capacity AS listing__capacity_latest + , listings_latest_src_28000.listing_id AS listing + , listings_latest_src_28000.user_id AS user + , listings_latest_src_28000.user_id AS listing__user + FROM ***************************.dim_listings_latest listings_latest_src_28000 + ) subq_12 + ) subq_13 + ) subq_14 + ON + subq_11.listing = subq_14.listing + ) subq_15 WHERE listing__is_lux_latest - ) subq_20 - ) subq_21 + ) subq_16 + ) subq_17 GROUP BY - subq_21.metric_time__day - ) subq_22 - ) subq_23 + subq_17.metric_time__day + ) subq_18 + ) subq_19 ON - subq_11.metric_time__day = subq_23.metric_time__day + subq_9.metric_time__day = subq_19.metric_time__day FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_27.metric_time__day - , subq_27.booking_value + subq_23.metric_time__day + , subq_23.booking_value FROM ( -- Aggregate Measures SELECT - subq_26.metric_time__day - , SUM(subq_26.booking_value) AS booking_value + subq_22.metric_time__day + , SUM(subq_22.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_21.metric_time__day + , subq_21.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_20.ds__day + , subq_20.ds__week + , subq_20.ds__month + , subq_20.ds__quarter + , subq_20.ds__year + , subq_20.ds__extract_year + , subq_20.ds__extract_quarter + , subq_20.ds__extract_month + , subq_20.ds__extract_day + , subq_20.ds__extract_dow + , subq_20.ds__extract_doy + , subq_20.ds_partitioned__day + , subq_20.ds_partitioned__week + , subq_20.ds_partitioned__month + , subq_20.ds_partitioned__quarter + , subq_20.ds_partitioned__year + , subq_20.ds_partitioned__extract_year + , subq_20.ds_partitioned__extract_quarter + , subq_20.ds_partitioned__extract_month + , subq_20.ds_partitioned__extract_day + , subq_20.ds_partitioned__extract_dow + , subq_20.ds_partitioned__extract_doy + , subq_20.paid_at__day + , subq_20.paid_at__week + , subq_20.paid_at__month + , subq_20.paid_at__quarter + , subq_20.paid_at__year + , subq_20.paid_at__extract_year + , subq_20.paid_at__extract_quarter + , subq_20.paid_at__extract_month + , subq_20.paid_at__extract_day + , subq_20.paid_at__extract_dow + , subq_20.paid_at__extract_doy + , subq_20.booking__ds__day + , subq_20.booking__ds__week + , subq_20.booking__ds__month + , subq_20.booking__ds__quarter + , subq_20.booking__ds__year + , subq_20.booking__ds__extract_year + , subq_20.booking__ds__extract_quarter + , subq_20.booking__ds__extract_month + , subq_20.booking__ds__extract_day + , subq_20.booking__ds__extract_dow + , subq_20.booking__ds__extract_doy + , subq_20.booking__ds_partitioned__day + , subq_20.booking__ds_partitioned__week + , subq_20.booking__ds_partitioned__month + , subq_20.booking__ds_partitioned__quarter + , subq_20.booking__ds_partitioned__year + , subq_20.booking__ds_partitioned__extract_year + , subq_20.booking__ds_partitioned__extract_quarter + , subq_20.booking__ds_partitioned__extract_month + , subq_20.booking__ds_partitioned__extract_day + , subq_20.booking__ds_partitioned__extract_dow + , subq_20.booking__ds_partitioned__extract_doy + , subq_20.booking__paid_at__day + , subq_20.booking__paid_at__week + , subq_20.booking__paid_at__month + , subq_20.booking__paid_at__quarter + , subq_20.booking__paid_at__year + , subq_20.booking__paid_at__extract_year + , subq_20.booking__paid_at__extract_quarter + , subq_20.booking__paid_at__extract_month + , subq_20.booking__paid_at__extract_day + , subq_20.booking__paid_at__extract_dow + , subq_20.booking__paid_at__extract_doy + , subq_20.ds__day AS metric_time__day + , subq_20.ds__week AS metric_time__week + , subq_20.ds__month AS metric_time__month + , subq_20.ds__quarter AS metric_time__quarter + , subq_20.ds__year AS metric_time__year + , subq_20.ds__extract_year AS metric_time__extract_year + , subq_20.ds__extract_quarter AS metric_time__extract_quarter + , subq_20.ds__extract_month AS metric_time__extract_month + , subq_20.ds__extract_day AS metric_time__extract_day + , subq_20.ds__extract_dow AS metric_time__extract_dow + , subq_20.ds__extract_doy AS metric_time__extract_doy + , subq_20.listing + , subq_20.guest + , subq_20.host + , subq_20.booking__listing + , subq_20.booking__guest + , subq_20.booking__host + , subq_20.is_instant + , subq_20.booking__is_instant + , subq_20.bookings + , subq_20.instant_bookings + , subq_20.booking_value + , subq_20.max_booking_value + , subq_20.min_booking_value + , subq_20.bookers + , subq_20.average_booking_value + , subq_20.referred_bookings + , subq_20.median_booking_value + , subq_20.booking_value_p99 + , subq_20.discrete_booking_value_p99 + , subq_20.approximate_continuous_booking_value_p99 + , subq_20.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -989,15 +1343,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_24 - ) subq_25 - ) subq_26 + ) subq_20 + ) subq_21 + ) subq_22 GROUP BY - subq_26.metric_time__day - ) subq_27 - ) subq_28 + subq_22.metric_time__day + ) subq_23 + ) subq_24 ON - COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + COALESCE(subq_9.metric_time__day, subq_19.metric_time__day) = subq_24.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_9.metric_time__day, subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql index 3b5d6bfe50..aec1662154 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/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_46.metric_time__day) AS metric_time__day - , MAX(subq_41.average_booking_value) AS average_booking_value - , MAX(subq_41.bookings) AS bookings - , MAX(subq_46.booking_value) AS booking_value + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) AS metric_time__day + , MAX(subq_35.average_booking_value) AS average_booking_value + , MAX(subq_35.bookings) AS bookings + , MAX(subq_40.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day'] @@ -20,32 +20,30 @@ FROM ( , SUM(bookings) AS bookings FROM ( -- Join Standard Outputs - -- Pass Only Elements: ['average_booking_value', 'bookings', 'listing__is_lux_latest', 'metric_time__day'] SELECT - subq_32.metric_time__day AS metric_time__day - , listings_latest_src_28000.is_lux AS listing__is_lux_latest - , subq_32.bookings AS bookings - , subq_32.average_booking_value AS average_booking_value + listings_latest_src_28000.is_lux AS listing__is_lux_latest + , subq_27.metric_time__day AS metric_time__day + , subq_27.bookings AS bookings + , subq_27.average_booking_value AS average_booking_value FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['average_booking_value', 'bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings , booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_32 + ) subq_27 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 ON - subq_32.listing = listings_latest_src_28000.listing_id - ) subq_37 + subq_27.listing = listings_latest_src_28000.listing_id + ) subq_31 WHERE listing__is_lux_latest GROUP BY metric_time__day - ) subq_41 + ) subq_35 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +56,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_46 + ) subq_40 ON - subq_41.metric_time__day = subq_46.metric_time__day + subq_35.metric_time__day = subq_40.metric_time__day GROUP BY - COALESCE(subq_41.metric_time__day, subq_46.metric_time__day) -) subq_47 + COALESCE(subq_35.metric_time__day, subq_40.metric_time__day) +) subq_41 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql index d757f7bc0b..6774f913cc 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0.sql @@ -1,359 +1,447 @@ -- 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_11.metric_time__day + , CAST(subq_11.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_11.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_5.metric_time__day, subq_10.metric_time__day) AS metric_time__day + , MAX(subq_5.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_10.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_4.metric_time__day + , subq_4.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_3.metric_time__day + , SUM(subq_3.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_2.metric_time__day + , subq_2.booking_value FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.booking_value + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.booking_value + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 - ) subq_6 + subq_3.metric_time__day + ) subq_4 + ) subq_5 FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.booking_value + subq_9.metric_time__day + , subq_9.booking_value FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , SUM(subq_9.booking_value) AS booking_value + subq_8.metric_time__day + , SUM(subq_8.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_7.metric_time__day + , subq_7.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_6.ds__day + , subq_6.ds__week + , subq_6.ds__month + , subq_6.ds__quarter + , subq_6.ds__year + , subq_6.ds__extract_year + , subq_6.ds__extract_quarter + , subq_6.ds__extract_month + , subq_6.ds__extract_day + , subq_6.ds__extract_dow + , subq_6.ds__extract_doy + , subq_6.ds_partitioned__day + , subq_6.ds_partitioned__week + , subq_6.ds_partitioned__month + , subq_6.ds_partitioned__quarter + , subq_6.ds_partitioned__year + , subq_6.ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy + , subq_6.paid_at__day + , subq_6.paid_at__week + , subq_6.paid_at__month + , subq_6.paid_at__quarter + , subq_6.paid_at__year + , subq_6.paid_at__extract_year + , subq_6.paid_at__extract_quarter + , subq_6.paid_at__extract_month + , subq_6.paid_at__extract_day + , subq_6.paid_at__extract_dow + , subq_6.paid_at__extract_doy + , subq_6.booking__ds__day + , subq_6.booking__ds__week + , subq_6.booking__ds__month + , subq_6.booking__ds__quarter + , subq_6.booking__ds__year + , subq_6.booking__ds__extract_year + , subq_6.booking__ds__extract_quarter + , subq_6.booking__ds__extract_month + , subq_6.booking__ds__extract_day + , subq_6.booking__ds__extract_dow + , subq_6.booking__ds__extract_doy + , subq_6.booking__ds_partitioned__day + , subq_6.booking__ds_partitioned__week + , subq_6.booking__ds_partitioned__month + , subq_6.booking__ds_partitioned__quarter + , subq_6.booking__ds_partitioned__year + , subq_6.booking__ds_partitioned__extract_year + , subq_6.booking__ds_partitioned__extract_quarter + , subq_6.booking__ds_partitioned__extract_month + , subq_6.booking__ds_partitioned__extract_day + , subq_6.booking__ds_partitioned__extract_dow + , subq_6.booking__ds_partitioned__extract_doy + , subq_6.booking__paid_at__day + , subq_6.booking__paid_at__week + , subq_6.booking__paid_at__month + , subq_6.booking__paid_at__quarter + , subq_6.booking__paid_at__year + , subq_6.booking__paid_at__extract_year + , subq_6.booking__paid_at__extract_quarter + , subq_6.booking__paid_at__extract_month + , subq_6.booking__paid_at__extract_day + , subq_6.booking__paid_at__extract_dow + , subq_6.booking__paid_at__extract_doy + , subq_6.ds__day AS metric_time__day + , subq_6.ds__week AS metric_time__week + , subq_6.ds__month AS metric_time__month + , subq_6.ds__quarter AS metric_time__quarter + , subq_6.ds__year AS metric_time__year + , subq_6.ds__extract_year AS metric_time__extract_year + , subq_6.ds__extract_quarter AS metric_time__extract_quarter + , subq_6.ds__extract_month AS metric_time__extract_month + , subq_6.ds__extract_day AS metric_time__extract_day + , subq_6.ds__extract_dow AS metric_time__extract_dow + , subq_6.ds__extract_doy AS metric_time__extract_doy + , subq_6.listing + , subq_6.guest + , subq_6.host + , subq_6.booking__listing + , subq_6.booking__guest + , subq_6.booking__host + , subq_6.is_instant + , subq_6.booking__is_instant + , subq_6.bookings + , subq_6.instant_bookings + , subq_6.booking_value + , subq_6.max_booking_value + , subq_6.min_booking_value + , subq_6.bookers + , subq_6.average_booking_value + , subq_6.referred_bookings + , subq_6.median_booking_value + , subq_6.booking_value_p99 + , subq_6.discrete_booking_value_p99 + , subq_6.approximate_continuous_booking_value_p99 + , subq_6.approximate_discrete_booking_value_p99 FROM ( -- Read Elements From Semantic Model 'bookings_source' SELECT @@ -446,15 +534,15 @@ FROM ( , bookings_source_src_28000.guest_id AS booking__guest , bookings_source_src_28000.host_id AS booking__host FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_7 - ) subq_8 - ) subq_9 + ) subq_6 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - ) subq_10 - ) subq_11 + subq_8.metric_time__day + ) subq_9 + ) subq_10 ON - subq_6.metric_time__day = subq_11.metric_time__day + subq_5.metric_time__day = subq_10.metric_time__day GROUP BY - COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) -) subq_12 + COALESCE(subq_5.metric_time__day, subq_10.metric_time__day) +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql index a465dac6f6..a50ba5881c 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_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_17.metric_time__day, subq_22.metric_time__day) AS metric_time__day + , MAX(subq_17.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_22.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: ['booking_value', 'metric_time__day'] @@ -19,17 +19,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_15 + ) subq_13 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_19 + ) subq_17 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -42,9 +41,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 GROUP BY DATE_TRUNC('day', ds) - ) subq_24 + ) subq_22 ON - subq_19.metric_time__day = subq_24.metric_time__day + subq_17.metric_time__day = subq_22.metric_time__day GROUP BY - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) -) subq_25 + COALESCE(subq_17.metric_time__day, subq_22.metric_time__day) +) subq_23 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql index fa133adf99..6218df0f49 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -1,234 +1,322 @@ -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day + subq_5.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_4.metric_time__day + , subq_4.bookings AS delayed_bookings FROM ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE NOT booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 -) subq_6 + subq_3.metric_time__day + ) subq_4 +) subq_5 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index 3202b9915d..abf77d4144 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -13,14 +13,13 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_9 + ) subq_7 WHERE NOT booking__is_instant GROUP BY metric_time__day -) subq_13 +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql index 38184cbcf1..6e26e4a201 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0.sql @@ -1,294 +1,376 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__user__home_state_latest - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__user__home_state_latest + , subq_9.bookings FROM ( -- Aggregate Measures SELECT - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest - , SUM(subq_9.bookings) AS bookings + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__user__home_state_latest + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.user__home_state_latest AS listing__user__home_state_latest - , subq_7.window_start__day AS listing__window_start__day - , subq_7.window_end__day AS listing__window_end__day - , subq_2.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.user__home_state_latest AS listing__user__home_state_latest + , subq_6.window_start__day AS listing__window_start__day + , subq_6.window_end__day AS listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.window_start__day + , subq_5.window_end__day + , subq_5.listing + , subq_5.user__home_state_latest FROM ( -- Join Standard Outputs SELECT - subq_5.home_state_latest AS user__home_state_latest - , 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.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_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_4.home_state_latest AS user__home_state_latest + , subq_4.ds__day AS user__ds__day + , subq_4.ds__week AS user__ds__week + , subq_4.ds__month AS user__ds__month + , subq_4.ds__quarter AS user__ds__quarter + , subq_4.ds__year AS user__ds__year + , subq_4.ds__extract_year AS user__ds__extract_year + , subq_4.ds__extract_quarter AS user__ds__extract_quarter + , subq_4.ds__extract_month AS user__ds__extract_month + , subq_4.ds__extract_day AS user__ds__extract_day + , subq_4.ds__extract_dow AS user__ds__extract_dow + , subq_4.ds__extract_doy AS user__ds__extract_doy + , subq_2.window_start__day AS window_start__day + , subq_2.window_start__week AS window_start__week + , subq_2.window_start__month AS window_start__month + , subq_2.window_start__quarter AS window_start__quarter + , subq_2.window_start__year AS window_start__year + , subq_2.window_start__extract_year AS window_start__extract_year + , subq_2.window_start__extract_quarter AS window_start__extract_quarter + , subq_2.window_start__extract_month AS window_start__extract_month + , subq_2.window_start__extract_day AS window_start__extract_day + , subq_2.window_start__extract_dow AS window_start__extract_dow + , subq_2.window_start__extract_doy AS window_start__extract_doy + , subq_2.window_end__day AS window_end__day + , subq_2.window_end__week AS window_end__week + , subq_2.window_end__month AS window_end__month + , subq_2.window_end__quarter AS window_end__quarter + , subq_2.window_end__year AS window_end__year + , subq_2.window_end__extract_year AS window_end__extract_year + , subq_2.window_end__extract_quarter AS window_end__extract_quarter + , subq_2.window_end__extract_month AS window_end__extract_month + , subq_2.window_end__extract_day AS window_end__extract_day + , subq_2.window_end__extract_dow AS window_end__extract_dow + , subq_2.window_end__extract_doy AS window_end__extract_doy + , subq_2.listing__window_start__day AS listing__window_start__day + , subq_2.listing__window_start__week AS listing__window_start__week + , subq_2.listing__window_start__month AS listing__window_start__month + , subq_2.listing__window_start__quarter AS listing__window_start__quarter + , subq_2.listing__window_start__year AS listing__window_start__year + , subq_2.listing__window_start__extract_year AS listing__window_start__extract_year + , subq_2.listing__window_start__extract_quarter AS listing__window_start__extract_quarter + , subq_2.listing__window_start__extract_month AS listing__window_start__extract_month + , subq_2.listing__window_start__extract_day AS listing__window_start__extract_day + , subq_2.listing__window_start__extract_dow AS listing__window_start__extract_dow + , subq_2.listing__window_start__extract_doy AS listing__window_start__extract_doy + , subq_2.listing__window_end__day AS listing__window_end__day + , subq_2.listing__window_end__week AS listing__window_end__week + , subq_2.listing__window_end__month AS listing__window_end__month + , subq_2.listing__window_end__quarter AS listing__window_end__quarter + , subq_2.listing__window_end__year AS listing__window_end__year + , subq_2.listing__window_end__extract_year AS listing__window_end__extract_year + , subq_2.listing__window_end__extract_quarter AS listing__window_end__extract_quarter + , subq_2.listing__window_end__extract_month AS listing__window_end__extract_month + , subq_2.listing__window_end__extract_day AS listing__window_end__extract_day + , subq_2.listing__window_end__extract_dow AS listing__window_end__extract_dow + , subq_2.listing__window_end__extract_doy AS listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.user AS user + , subq_2.listing__user AS listing__user + , subq_2.country AS country + , subq_2.is_lux AS is_lux + , subq_2.capacity AS capacity + , subq_2.listing__country AS listing__country + , subq_2.listing__is_lux AS listing__is_lux + , subq_2.listing__capacity AS listing__capacity FROM ( -- Read Elements From Semantic Model 'listings' SELECT @@ -346,7 +428,7 @@ FROM ( , listings_src_26000.user_id AS user , listings_src_26000.user_id AS listing__user FROM ***************************.dim_listings listings_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'home_state_latest', @@ -376,31 +458,31 @@ 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_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.user__ds__day + , subq_3.user__ds__week + , subq_3.user__ds__month + , subq_3.user__ds__quarter + , subq_3.user__ds__year + , subq_3.user__ds__extract_year + , subq_3.user__ds__extract_quarter + , subq_3.user__ds__extract_month + , subq_3.user__ds__extract_day + , subq_3.user__ds__extract_dow + , subq_3.user__ds__extract_doy + , subq_3.user + , subq_3.home_state_latest + , subq_3.user__home_state_latest FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT @@ -430,29 +512,29 @@ FROM ( , users_latest_src_26000.home_state_latest AS user__home_state_latest , users_latest_src_26000.user_id AS user FROM ***************************.dim_users_latest users_latest_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.user = subq_5.user - ) subq_6 - ) subq_7 + subq_2.user = subq_4.user + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.window_start__day + subq_1.metric_time__day >= subq_6.window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.window_end__day + subq_1.metric_time__day < subq_6.window_end__day ) OR ( - subq_7.window_end__day IS NULL + subq_6.window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__user__home_state_latest -) subq_10 + subq_8.metric_time__day + , subq_8.listing__user__home_state_latest +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql index 43c459ada2..c693b5ecd5 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.user__home_state_latest AS listing__user__home_state_latest + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['user__home_state_latest', 'window_start__day', 'window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_users_latest users_latest_src_26000 ON listings_src_26000.user_id = users_latest_src_26000.user_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.window_start__day + subq_11.metric_time__day >= subq_16.window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.window_end__day + subq_11.metric_time__day < subq_16.window_end__day ) OR ( - subq_18.window_end__day IS NULL + subq_16.window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.user__home_state_latest + subq_11.metric_time__day + , subq_16.user__home_state_latest diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql index ab5787e746..2980d12266 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0.sql @@ -1,255 +1,337 @@ -- Compute Metrics via Expressions SELECT - subq_10.metric_time__day - , subq_10.listing__lux_listing__is_confirmed_lux - , subq_10.bookings + subq_9.metric_time__day + , subq_9.listing__lux_listing__is_confirmed_lux + , subq_9.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_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux + , SUM(subq_8.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_7.metric_time__day + , subq_7.listing__lux_listing__is_confirmed_lux + , subq_7.bookings FROM ( -- Join Standard Outputs SELECT - subq_7.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux - , 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.metric_time__day AS metric_time__day - , subq_2.listing AS listing - , subq_2.bookings AS bookings + subq_6.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , subq_6.lux_listing__window_start__day AS listing__lux_listing__window_start__day + , subq_6.lux_listing__window_end__day AS listing__lux_listing__window_end__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__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.user AS user + , subq_1.booking__listing AS booking__listing + , subq_1.booking__guest AS booking__guest + , subq_1.booking__host AS booking__host + , subq_1.booking__user AS booking__user + , 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.bookers AS bookers + , subq_1.average_booking_value AS average_booking_value FROM ( - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.user + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.booking__user + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.bookers + , subq_0.average_booking_value FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.user - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.booking__user - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.bookers - , subq_0.average_booking_value - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_26000.booking_value - , bookings_source_src_26000.guest_id AS bookers - , bookings_source_src_26000.booking_value AS average_booking_value - , bookings_source_src_26000.booking_value AS booking_payments - , bookings_source_src_26000.is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy - , bookings_source_src_26000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_26000.listing_id AS listing - , bookings_source_src_26000.guest_id AS guest - , bookings_source_src_26000.host_id AS host - , bookings_source_src_26000.guest_id AS user - , bookings_source_src_26000.listing_id AS booking__listing - , bookings_source_src_26000.guest_id AS booking__guest - , 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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_26000.booking_value + , bookings_source_src_26000.guest_id AS bookers + , bookings_source_src_26000.booking_value AS average_booking_value + , bookings_source_src_26000.booking_value AS booking_payments + , bookings_source_src_26000.is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS paid_at__extract_doy + , bookings_source_src_26000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_26000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_26000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_26000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_26000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_26000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_26000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_26000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_26000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_26000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_26000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_26000.listing_id AS listing + , bookings_source_src_26000.guest_id AS guest + , bookings_source_src_26000.host_id AS host + , bookings_source_src_26000.guest_id AS user + , bookings_source_src_26000.listing_id AS booking__listing + , bookings_source_src_26000.guest_id AS booking__guest + , 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 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_5.lux_listing__window_start__day + , subq_5.lux_listing__window_end__day + , subq_5.listing + , subq_5.lux_listing__is_confirmed_lux FROM ( -- Join Standard Outputs SELECT - subq_5.is_confirmed_lux AS lux_listing__is_confirmed_lux - , subq_5.window_start__day AS lux_listing__window_start__day - , subq_5.window_start__week AS lux_listing__window_start__week - , subq_5.window_start__month AS lux_listing__window_start__month - , subq_5.window_start__quarter AS lux_listing__window_start__quarter - , subq_5.window_start__year AS lux_listing__window_start__year - , subq_5.window_start__extract_year AS lux_listing__window_start__extract_year - , subq_5.window_start__extract_quarter AS lux_listing__window_start__extract_quarter - , subq_5.window_start__extract_month AS lux_listing__window_start__extract_month - , subq_5.window_start__extract_day AS lux_listing__window_start__extract_day - , subq_5.window_start__extract_dow AS lux_listing__window_start__extract_dow - , subq_5.window_start__extract_doy AS lux_listing__window_start__extract_doy - , subq_5.window_end__day AS lux_listing__window_end__day - , subq_5.window_end__week AS lux_listing__window_end__week - , subq_5.window_end__month AS lux_listing__window_end__month - , subq_5.window_end__quarter AS lux_listing__window_end__quarter - , subq_5.window_end__year AS lux_listing__window_end__year - , subq_5.window_end__extract_year AS lux_listing__window_end__extract_year - , subq_5.window_end__extract_quarter AS lux_listing__window_end__extract_quarter - , subq_5.window_end__extract_month AS lux_listing__window_end__extract_month - , subq_5.window_end__extract_day AS lux_listing__window_end__extract_day - , subq_5.window_end__extract_dow AS lux_listing__window_end__extract_dow - , subq_5.window_end__extract_doy AS lux_listing__window_end__extract_doy - , subq_3.listing AS listing - , subq_3.lux_listing AS lux_listing - , subq_3.listing__lux_listing AS listing__lux_listing + subq_4.is_confirmed_lux AS lux_listing__is_confirmed_lux + , subq_4.window_start__day AS lux_listing__window_start__day + , subq_4.window_start__week AS lux_listing__window_start__week + , subq_4.window_start__month AS lux_listing__window_start__month + , subq_4.window_start__quarter AS lux_listing__window_start__quarter + , subq_4.window_start__year AS lux_listing__window_start__year + , subq_4.window_start__extract_year AS lux_listing__window_start__extract_year + , subq_4.window_start__extract_quarter AS lux_listing__window_start__extract_quarter + , subq_4.window_start__extract_month AS lux_listing__window_start__extract_month + , subq_4.window_start__extract_day AS lux_listing__window_start__extract_day + , subq_4.window_start__extract_dow AS lux_listing__window_start__extract_dow + , subq_4.window_start__extract_doy AS lux_listing__window_start__extract_doy + , subq_4.window_end__day AS lux_listing__window_end__day + , subq_4.window_end__week AS lux_listing__window_end__week + , subq_4.window_end__month AS lux_listing__window_end__month + , subq_4.window_end__quarter AS lux_listing__window_end__quarter + , subq_4.window_end__year AS lux_listing__window_end__year + , subq_4.window_end__extract_year AS lux_listing__window_end__extract_year + , subq_4.window_end__extract_quarter AS lux_listing__window_end__extract_quarter + , subq_4.window_end__extract_month AS lux_listing__window_end__extract_month + , subq_4.window_end__extract_day AS lux_listing__window_end__extract_day + , subq_4.window_end__extract_dow AS lux_listing__window_end__extract_dow + , subq_4.window_end__extract_doy AS lux_listing__window_end__extract_doy + , subq_2.listing AS listing + , subq_2.lux_listing AS lux_listing + , subq_2.listing__lux_listing AS listing__lux_listing FROM ( -- Read Elements From Semantic Model 'lux_listing_mapping' SELECT @@ -257,7 +339,7 @@ FROM ( , lux_listing_mapping_src_26000.lux_listing_id AS lux_listing , lux_listing_mapping_src_26000.lux_listing_id AS listing__lux_listing FROM ***************************.dim_lux_listing_id_mapping lux_listing_mapping_src_26000 - ) subq_3 + ) subq_2 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'is_confirmed_lux', @@ -309,53 +391,53 @@ 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_3.window_start__day + , subq_3.window_start__week + , subq_3.window_start__month + , subq_3.window_start__quarter + , subq_3.window_start__year + , subq_3.window_start__extract_year + , subq_3.window_start__extract_quarter + , subq_3.window_start__extract_month + , subq_3.window_start__extract_day + , subq_3.window_start__extract_dow + , subq_3.window_start__extract_doy + , subq_3.window_end__day + , subq_3.window_end__week + , subq_3.window_end__month + , subq_3.window_end__quarter + , subq_3.window_end__year + , subq_3.window_end__extract_year + , subq_3.window_end__extract_quarter + , subq_3.window_end__extract_month + , subq_3.window_end__extract_day + , subq_3.window_end__extract_dow + , subq_3.window_end__extract_doy + , subq_3.lux_listing__window_start__day + , subq_3.lux_listing__window_start__week + , subq_3.lux_listing__window_start__month + , subq_3.lux_listing__window_start__quarter + , subq_3.lux_listing__window_start__year + , subq_3.lux_listing__window_start__extract_year + , subq_3.lux_listing__window_start__extract_quarter + , subq_3.lux_listing__window_start__extract_month + , subq_3.lux_listing__window_start__extract_day + , subq_3.lux_listing__window_start__extract_dow + , subq_3.lux_listing__window_start__extract_doy + , subq_3.lux_listing__window_end__day + , subq_3.lux_listing__window_end__week + , subq_3.lux_listing__window_end__month + , subq_3.lux_listing__window_end__quarter + , subq_3.lux_listing__window_end__year + , subq_3.lux_listing__window_end__extract_year + , subq_3.lux_listing__window_end__extract_quarter + , subq_3.lux_listing__window_end__extract_month + , subq_3.lux_listing__window_end__extract_day + , subq_3.lux_listing__window_end__extract_dow + , subq_3.lux_listing__window_end__extract_doy + , subq_3.lux_listing + , subq_3.is_confirmed_lux + , subq_3.lux_listing__is_confirmed_lux FROM ( -- Read Elements From Semantic Model 'lux_listings' SELECT @@ -407,29 +489,29 @@ FROM ( , lux_listings_src_26000.is_confirmed_lux AS lux_listing__is_confirmed_lux , lux_listings_src_26000.lux_listing_id AS lux_listing FROM ***************************.dim_lux_listings lux_listings_src_26000 - ) subq_4 - ) subq_5 + ) subq_3 + ) subq_4 ON - subq_3.lux_listing = subq_5.lux_listing - ) subq_6 - ) subq_7 + subq_2.lux_listing = subq_4.lux_listing + ) subq_5 + ) subq_6 ON ( - subq_2.listing = subq_7.listing + subq_1.listing = subq_6.listing ) AND ( ( - subq_2.metric_time__day >= subq_7.lux_listing__window_start__day + subq_1.metric_time__day >= subq_6.lux_listing__window_start__day ) AND ( ( - subq_2.metric_time__day < subq_7.lux_listing__window_end__day + subq_1.metric_time__day < subq_6.lux_listing__window_end__day ) OR ( - subq_7.lux_listing__window_end__day IS NULL + subq_6.lux_listing__window_end__day IS NULL ) ) ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 GROUP BY - subq_9.metric_time__day - , subq_9.listing__lux_listing__is_confirmed_lux -) subq_10 + subq_8.metric_time__day + , subq_8.listing__lux_listing__is_confirmed_lux +) subq_9 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql index d0d6125e14..147c41636f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -3,19 +3,18 @@ -- 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_11.metric_time__day AS metric_time__day + , subq_16.lux_listing__is_confirmed_lux AS listing__lux_listing__is_confirmed_lux + , SUM(subq_11.bookings) AS bookings FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_26000 -) subq_13 +) subq_11 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['lux_listing__is_confirmed_lux', 'lux_listing__window_start__day', 'lux_listing__window_end__day', 'listing'] @@ -29,21 +28,21 @@ LEFT OUTER JOIN ( ***************************.dim_lux_listings lux_listings_src_26000 ON lux_listing_mapping_src_26000.lux_listing_id = lux_listings_src_26000.lux_listing_id -) subq_18 +) subq_16 ON ( - subq_13.listing = subq_18.listing + subq_11.listing = subq_16.listing ) AND ( ( - subq_13.metric_time__day >= subq_18.lux_listing__window_start__day + subq_11.metric_time__day >= subq_16.lux_listing__window_start__day ) AND ( ( - subq_13.metric_time__day < subq_18.lux_listing__window_end__day + subq_11.metric_time__day < subq_16.lux_listing__window_end__day ) OR ( - subq_18.lux_listing__window_end__day IS NULL + subq_16.lux_listing__window_end__day IS NULL ) ) ) GROUP BY - subq_13.metric_time__day - , subq_18.lux_listing__is_confirmed_lux + subq_11.metric_time__day + , subq_16.lux_listing__is_confirmed_lux diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql index 5b4334b3c5..a192266a70 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0.sql @@ -1,290 +1,339 @@ -- Compute Metrics via Expressions SELECT - subq_12.account_id__customer_id__customer_name - , subq_12.txn_count + subq_11.account_id__customer_id__customer_name + , subq_11.txn_count FROM ( -- Aggregate Measures SELECT - subq_11.account_id__customer_id__customer_name - , SUM(subq_11.txn_count) AS txn_count + subq_10.account_id__customer_id__customer_name + , SUM(subq_10.txn_count) AS txn_count FROM ( -- Pass Only Elements: ['txn_count', 'account_id__customer_id__customer_name'] SELECT - subq_10.account_id__customer_id__customer_name - , subq_10.txn_count + subq_9.account_id__customer_id__customer_name + , subq_9.txn_count FROM ( -- Join Standard Outputs SELECT - subq_9.customer_id__customer_name AS account_id__customer_id__customer_name - , subq_9.ds_partitioned__day AS account_id__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.account_id AS account_id - , subq_2.txn_count AS txn_count + subq_8.customer_id__customer_name AS account_id__customer_id__customer_name + , subq_8.ds_partitioned__day AS account_id__ds_partitioned__day + , 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.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.account_id__ds_partitioned__day AS account_id__ds_partitioned__day + , subq_1.account_id__ds_partitioned__week AS account_id__ds_partitioned__week + , subq_1.account_id__ds_partitioned__month AS account_id__ds_partitioned__month + , subq_1.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter + , subq_1.account_id__ds_partitioned__year AS account_id__ds_partitioned__year + , subq_1.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year + , subq_1.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter + , subq_1.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month + , subq_1.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day + , subq_1.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow + , subq_1.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy + , subq_1.account_id__ds__day AS account_id__ds__day + , subq_1.account_id__ds__week AS account_id__ds__week + , subq_1.account_id__ds__month AS account_id__ds__month + , subq_1.account_id__ds__quarter AS account_id__ds__quarter + , subq_1.account_id__ds__year AS account_id__ds__year + , subq_1.account_id__ds__extract_year AS account_id__ds__extract_year + , subq_1.account_id__ds__extract_quarter AS account_id__ds__extract_quarter + , subq_1.account_id__ds__extract_month AS account_id__ds__extract_month + , subq_1.account_id__ds__extract_day AS account_id__ds__extract_day + , subq_1.account_id__ds__extract_dow AS account_id__ds__extract_dow + , subq_1.account_id__ds__extract_doy AS account_id__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.account_id AS account_id + , subq_1.account_month AS account_month + , subq_1.account_id__account_month AS account_id__account_month + , subq_1.txn_count AS txn_count FROM ( - -- Pass Only Elements: ['txn_count', 'ds_partitioned__day', 'account_id'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.account_id - , subq_1.txn_count + subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.account_id__ds_partitioned__day + , subq_0.account_id__ds_partitioned__week + , subq_0.account_id__ds_partitioned__month + , subq_0.account_id__ds_partitioned__quarter + , subq_0.account_id__ds_partitioned__year + , subq_0.account_id__ds_partitioned__extract_year + , subq_0.account_id__ds_partitioned__extract_quarter + , subq_0.account_id__ds_partitioned__extract_month + , subq_0.account_id__ds_partitioned__extract_day + , subq_0.account_id__ds_partitioned__extract_dow + , subq_0.account_id__ds_partitioned__extract_doy + , subq_0.account_id__ds__day + , subq_0.account_id__ds__week + , subq_0.account_id__ds__month + , subq_0.account_id__ds__quarter + , subq_0.account_id__ds__year + , subq_0.account_id__ds__extract_year + , subq_0.account_id__ds__extract_quarter + , subq_0.account_id__ds__extract_month + , subq_0.account_id__ds__extract_day + , subq_0.account_id__ds__extract_dow + , subq_0.account_id__ds__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.account_id + , subq_0.account_month + , subq_0.account_id__account_month + , subq_0.txn_count FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'account_month_txns' 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 - FROM ( - -- Read Elements From Semantic Model 'account_month_txns' - SELECT - account_month_txns_src_22000.txn_count - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy - , account_month_txns_src_22000.account_month - , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year - , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day - , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week - , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month - , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter - , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year - , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year - , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter - , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month - , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow - , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy - , 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 + account_month_txns_src_22000.txn_count + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS ds__extract_doy + , account_month_txns_src_22000.account_month + , DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__year + , EXTRACT(year FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds_partitioned) AS account_id__ds_partitioned__extract_doy + , DATE_TRUNC('day', account_month_txns_src_22000.ds) AS account_id__ds__day + , DATE_TRUNC('week', account_month_txns_src_22000.ds) AS account_id__ds__week + , DATE_TRUNC('month', account_month_txns_src_22000.ds) AS account_id__ds__month + , DATE_TRUNC('quarter', account_month_txns_src_22000.ds) AS account_id__ds__quarter + , DATE_TRUNC('year', account_month_txns_src_22000.ds) AS account_id__ds__year + , EXTRACT(year FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_year + , EXTRACT(quarter FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_quarter + , EXTRACT(month FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_month + , EXTRACT(day FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_dow + , EXTRACT(doy FROM account_month_txns_src_22000.ds) AS account_id__ds__extract_doy + , 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 LEFT OUTER JOIN ( -- Pass Only Elements: ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - subq_8.ds_partitioned__day - , subq_8.account_id - , subq_8.customer_id__customer_name + subq_7.ds_partitioned__day + , subq_7.account_id + , subq_7.customer_id__customer_name FROM ( -- Join Standard Outputs SELECT - subq_7.customer_name AS customer_id__customer_name - , subq_7.customer_atomic_weight AS customer_id__customer_atomic_weight - , subq_7.ds_partitioned__day AS customer_id__ds_partitioned__day - , subq_7.ds_partitioned__week AS customer_id__ds_partitioned__week - , subq_7.ds_partitioned__month AS customer_id__ds_partitioned__month - , subq_7.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter - , subq_7.ds_partitioned__year AS customer_id__ds_partitioned__year - , subq_7.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year - , subq_7.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter - , subq_7.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month - , subq_7.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day - , subq_7.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow - , subq_7.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy - , subq_7.metric_time__day AS customer_id__metric_time__day - , subq_7.metric_time__week AS customer_id__metric_time__week - , subq_7.metric_time__month AS customer_id__metric_time__month - , subq_7.metric_time__quarter AS customer_id__metric_time__quarter - , subq_7.metric_time__year AS customer_id__metric_time__year - , subq_7.metric_time__extract_year AS customer_id__metric_time__extract_year - , subq_7.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter - , subq_7.metric_time__extract_month AS customer_id__metric_time__extract_month - , subq_7.metric_time__extract_day AS customer_id__metric_time__extract_day - , subq_7.metric_time__extract_dow AS customer_id__metric_time__extract_dow - , subq_7.metric_time__extract_doy AS customer_id__metric_time__extract_doy - , subq_4.ds_partitioned__day AS ds_partitioned__day - , subq_4.ds_partitioned__week AS ds_partitioned__week - , subq_4.ds_partitioned__month AS ds_partitioned__month - , subq_4.ds_partitioned__quarter AS ds_partitioned__quarter - , subq_4.ds_partitioned__year AS ds_partitioned__year - , subq_4.ds_partitioned__extract_year AS ds_partitioned__extract_year - , subq_4.ds_partitioned__extract_quarter AS ds_partitioned__extract_quarter - , subq_4.ds_partitioned__extract_month AS ds_partitioned__extract_month - , subq_4.ds_partitioned__extract_day AS ds_partitioned__extract_day - , subq_4.ds_partitioned__extract_dow AS ds_partitioned__extract_dow - , subq_4.ds_partitioned__extract_doy AS ds_partitioned__extract_doy - , subq_4.account_id__ds_partitioned__day AS account_id__ds_partitioned__day - , subq_4.account_id__ds_partitioned__week AS account_id__ds_partitioned__week - , subq_4.account_id__ds_partitioned__month AS account_id__ds_partitioned__month - , subq_4.account_id__ds_partitioned__quarter AS account_id__ds_partitioned__quarter - , subq_4.account_id__ds_partitioned__year AS account_id__ds_partitioned__year - , subq_4.account_id__ds_partitioned__extract_year AS account_id__ds_partitioned__extract_year - , subq_4.account_id__ds_partitioned__extract_quarter AS account_id__ds_partitioned__extract_quarter - , subq_4.account_id__ds_partitioned__extract_month AS account_id__ds_partitioned__extract_month - , subq_4.account_id__ds_partitioned__extract_day AS account_id__ds_partitioned__extract_day - , subq_4.account_id__ds_partitioned__extract_dow AS account_id__ds_partitioned__extract_dow - , subq_4.account_id__ds_partitioned__extract_doy AS account_id__ds_partitioned__extract_doy - , subq_4.bridge_account__ds_partitioned__day AS bridge_account__ds_partitioned__day - , subq_4.bridge_account__ds_partitioned__week AS bridge_account__ds_partitioned__week - , subq_4.bridge_account__ds_partitioned__month AS bridge_account__ds_partitioned__month - , subq_4.bridge_account__ds_partitioned__quarter AS bridge_account__ds_partitioned__quarter - , subq_4.bridge_account__ds_partitioned__year AS bridge_account__ds_partitioned__year - , subq_4.bridge_account__ds_partitioned__extract_year AS bridge_account__ds_partitioned__extract_year - , subq_4.bridge_account__ds_partitioned__extract_quarter AS bridge_account__ds_partitioned__extract_quarter - , subq_4.bridge_account__ds_partitioned__extract_month AS bridge_account__ds_partitioned__extract_month - , subq_4.bridge_account__ds_partitioned__extract_day AS bridge_account__ds_partitioned__extract_day - , subq_4.bridge_account__ds_partitioned__extract_dow AS bridge_account__ds_partitioned__extract_dow - , subq_4.bridge_account__ds_partitioned__extract_doy AS bridge_account__ds_partitioned__extract_doy - , subq_4.metric_time__day AS metric_time__day - , subq_4.metric_time__week AS metric_time__week - , subq_4.metric_time__month AS metric_time__month - , subq_4.metric_time__quarter AS metric_time__quarter - , subq_4.metric_time__year AS metric_time__year - , subq_4.metric_time__extract_year AS metric_time__extract_year - , subq_4.metric_time__extract_quarter AS metric_time__extract_quarter - , subq_4.metric_time__extract_month AS metric_time__extract_month - , subq_4.metric_time__extract_day AS metric_time__extract_day - , subq_4.metric_time__extract_dow AS metric_time__extract_dow - , subq_4.metric_time__extract_doy AS metric_time__extract_doy - , subq_4.account_id AS account_id - , subq_4.customer_id AS customer_id - , subq_4.account_id__customer_id AS account_id__customer_id - , subq_4.bridge_account__account_id AS bridge_account__account_id - , subq_4.bridge_account__customer_id AS bridge_account__customer_id - , subq_4.extra_dim AS extra_dim - , subq_4.account_id__extra_dim AS account_id__extra_dim - , subq_4.bridge_account__extra_dim AS bridge_account__extra_dim - , subq_4.account_customer_combos AS account_customer_combos + subq_6.customer_name AS customer_id__customer_name + , subq_6.customer_atomic_weight AS customer_id__customer_atomic_weight + , subq_6.ds_partitioned__day AS customer_id__ds_partitioned__day + , subq_6.ds_partitioned__week AS customer_id__ds_partitioned__week + , subq_6.ds_partitioned__month AS customer_id__ds_partitioned__month + , subq_6.ds_partitioned__quarter AS customer_id__ds_partitioned__quarter + , subq_6.ds_partitioned__year AS customer_id__ds_partitioned__year + , subq_6.ds_partitioned__extract_year AS customer_id__ds_partitioned__extract_year + , subq_6.ds_partitioned__extract_quarter AS customer_id__ds_partitioned__extract_quarter + , subq_6.ds_partitioned__extract_month AS customer_id__ds_partitioned__extract_month + , subq_6.ds_partitioned__extract_day AS customer_id__ds_partitioned__extract_day + , subq_6.ds_partitioned__extract_dow AS customer_id__ds_partitioned__extract_dow + , subq_6.ds_partitioned__extract_doy AS customer_id__ds_partitioned__extract_doy + , subq_6.metric_time__day AS customer_id__metric_time__day + , subq_6.metric_time__week AS customer_id__metric_time__week + , subq_6.metric_time__month AS customer_id__metric_time__month + , subq_6.metric_time__quarter AS customer_id__metric_time__quarter + , subq_6.metric_time__year AS customer_id__metric_time__year + , subq_6.metric_time__extract_year AS customer_id__metric_time__extract_year + , subq_6.metric_time__extract_quarter AS customer_id__metric_time__extract_quarter + , subq_6.metric_time__extract_month AS customer_id__metric_time__extract_month + , subq_6.metric_time__extract_day AS customer_id__metric_time__extract_day + , subq_6.metric_time__extract_dow AS customer_id__metric_time__extract_dow + , subq_6.metric_time__extract_doy AS customer_id__metric_time__extract_doy + , 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_3.metric_time__day AS metric_time__day + , subq_3.metric_time__week AS metric_time__week + , subq_3.metric_time__month AS metric_time__month + , subq_3.metric_time__quarter AS metric_time__quarter + , subq_3.metric_time__year AS metric_time__year + , subq_3.metric_time__extract_year AS metric_time__extract_year + , subq_3.metric_time__extract_quarter AS metric_time__extract_quarter + , subq_3.metric_time__extract_month AS metric_time__extract_month + , subq_3.metric_time__extract_day AS metric_time__extract_day + , subq_3.metric_time__extract_dow AS metric_time__extract_dow + , subq_3.metric_time__extract_doy AS metric_time__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_3.account_customer_combos AS account_customer_combos FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_3.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.account_id__ds_partitioned__day - , subq_3.account_id__ds_partitioned__week - , subq_3.account_id__ds_partitioned__month - , subq_3.account_id__ds_partitioned__quarter - , subq_3.account_id__ds_partitioned__year - , subq_3.account_id__ds_partitioned__extract_year - , subq_3.account_id__ds_partitioned__extract_quarter - , subq_3.account_id__ds_partitioned__extract_month - , subq_3.account_id__ds_partitioned__extract_day - , subq_3.account_id__ds_partitioned__extract_dow - , subq_3.account_id__ds_partitioned__extract_doy - , subq_3.bridge_account__ds_partitioned__day - , subq_3.bridge_account__ds_partitioned__week - , subq_3.bridge_account__ds_partitioned__month - , subq_3.bridge_account__ds_partitioned__quarter - , subq_3.bridge_account__ds_partitioned__year - , subq_3.bridge_account__ds_partitioned__extract_year - , subq_3.bridge_account__ds_partitioned__extract_quarter - , subq_3.bridge_account__ds_partitioned__extract_month - , subq_3.bridge_account__ds_partitioned__extract_day - , subq_3.bridge_account__ds_partitioned__extract_dow - , subq_3.bridge_account__ds_partitioned__extract_doy - , subq_3.ds_partitioned__day AS metric_time__day - , subq_3.ds_partitioned__week AS metric_time__week - , subq_3.ds_partitioned__month AS metric_time__month - , subq_3.ds_partitioned__quarter AS metric_time__quarter - , subq_3.ds_partitioned__year AS metric_time__year - , subq_3.ds_partitioned__extract_year AS metric_time__extract_year - , subq_3.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_3.ds_partitioned__extract_month AS metric_time__extract_month - , subq_3.ds_partitioned__extract_day AS metric_time__extract_day - , subq_3.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_3.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_3.account_id - , subq_3.customer_id - , subq_3.account_id__customer_id - , subq_3.bridge_account__account_id - , subq_3.bridge_account__customer_id - , subq_3.extra_dim - , subq_3.account_id__extra_dim - , subq_3.bridge_account__extra_dim - , subq_3.account_customer_combos + 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.account_id__ds_partitioned__day + , subq_2.account_id__ds_partitioned__week + , subq_2.account_id__ds_partitioned__month + , subq_2.account_id__ds_partitioned__quarter + , subq_2.account_id__ds_partitioned__year + , subq_2.account_id__ds_partitioned__extract_year + , subq_2.account_id__ds_partitioned__extract_quarter + , subq_2.account_id__ds_partitioned__extract_month + , subq_2.account_id__ds_partitioned__extract_day + , subq_2.account_id__ds_partitioned__extract_dow + , subq_2.account_id__ds_partitioned__extract_doy + , subq_2.bridge_account__ds_partitioned__day + , subq_2.bridge_account__ds_partitioned__week + , subq_2.bridge_account__ds_partitioned__month + , subq_2.bridge_account__ds_partitioned__quarter + , subq_2.bridge_account__ds_partitioned__year + , subq_2.bridge_account__ds_partitioned__extract_year + , subq_2.bridge_account__ds_partitioned__extract_quarter + , subq_2.bridge_account__ds_partitioned__extract_month + , subq_2.bridge_account__ds_partitioned__extract_day + , subq_2.bridge_account__ds_partitioned__extract_dow + , subq_2.bridge_account__ds_partitioned__extract_doy + , subq_2.ds_partitioned__day AS metric_time__day + , subq_2.ds_partitioned__week AS metric_time__week + , subq_2.ds_partitioned__month AS metric_time__month + , subq_2.ds_partitioned__quarter AS metric_time__quarter + , subq_2.ds_partitioned__year AS metric_time__year + , subq_2.ds_partitioned__extract_year AS metric_time__extract_year + , subq_2.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_2.ds_partitioned__extract_month AS metric_time__extract_month + , subq_2.ds_partitioned__extract_day AS metric_time__extract_day + , subq_2.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_2.ds_partitioned__extract_doy AS metric_time__extract_doy + , subq_2.account_id + , subq_2.customer_id + , subq_2.account_id__customer_id + , subq_2.bridge_account__account_id + , subq_2.bridge_account__customer_id + , subq_2.extra_dim + , subq_2.account_id__extra_dim + , subq_2.bridge_account__extra_dim + , subq_2.account_customer_combos FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT @@ -331,8 +380,8 @@ FROM ( , bridge_table_src_22000.account_id AS bridge_account__account_id , bridge_table_src_22000.customer_id AS bridge_account__customer_id FROM ***************************.bridge_table bridge_table_src_22000 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 LEFT OUTER JOIN ( -- Pass Only Elements: [ -- 'customer_name', @@ -375,86 +424,86 @@ FROM ( -- 'customer_id', -- ] SELECT - subq_6.ds_partitioned__day - , subq_6.ds_partitioned__week - , subq_6.ds_partitioned__month - , subq_6.ds_partitioned__quarter - , subq_6.ds_partitioned__year - , subq_6.ds_partitioned__extract_year - , subq_6.ds_partitioned__extract_quarter - , subq_6.ds_partitioned__extract_month - , subq_6.ds_partitioned__extract_day - , subq_6.ds_partitioned__extract_dow - , subq_6.ds_partitioned__extract_doy - , subq_6.customer_id__ds_partitioned__day - , subq_6.customer_id__ds_partitioned__week - , subq_6.customer_id__ds_partitioned__month - , subq_6.customer_id__ds_partitioned__quarter - , subq_6.customer_id__ds_partitioned__year - , subq_6.customer_id__ds_partitioned__extract_year - , subq_6.customer_id__ds_partitioned__extract_quarter - , subq_6.customer_id__ds_partitioned__extract_month - , subq_6.customer_id__ds_partitioned__extract_day - , subq_6.customer_id__ds_partitioned__extract_dow - , subq_6.customer_id__ds_partitioned__extract_doy - , subq_6.metric_time__day - , subq_6.metric_time__week - , subq_6.metric_time__month - , subq_6.metric_time__quarter - , subq_6.metric_time__year - , subq_6.metric_time__extract_year - , subq_6.metric_time__extract_quarter - , subq_6.metric_time__extract_month - , subq_6.metric_time__extract_day - , subq_6.metric_time__extract_dow - , subq_6.metric_time__extract_doy - , subq_6.customer_id - , subq_6.customer_name - , subq_6.customer_atomic_weight - , subq_6.customer_id__customer_name - , subq_6.customer_id__customer_atomic_weight + subq_5.ds_partitioned__day + , subq_5.ds_partitioned__week + , subq_5.ds_partitioned__month + , subq_5.ds_partitioned__quarter + , subq_5.ds_partitioned__year + , subq_5.ds_partitioned__extract_year + , subq_5.ds_partitioned__extract_quarter + , subq_5.ds_partitioned__extract_month + , subq_5.ds_partitioned__extract_day + , subq_5.ds_partitioned__extract_dow + , subq_5.ds_partitioned__extract_doy + , subq_5.customer_id__ds_partitioned__day + , subq_5.customer_id__ds_partitioned__week + , subq_5.customer_id__ds_partitioned__month + , subq_5.customer_id__ds_partitioned__quarter + , subq_5.customer_id__ds_partitioned__year + , subq_5.customer_id__ds_partitioned__extract_year + , subq_5.customer_id__ds_partitioned__extract_quarter + , subq_5.customer_id__ds_partitioned__extract_month + , subq_5.customer_id__ds_partitioned__extract_day + , subq_5.customer_id__ds_partitioned__extract_dow + , subq_5.customer_id__ds_partitioned__extract_doy + , subq_5.metric_time__day + , subq_5.metric_time__week + , subq_5.metric_time__month + , subq_5.metric_time__quarter + , subq_5.metric_time__year + , subq_5.metric_time__extract_year + , subq_5.metric_time__extract_quarter + , subq_5.metric_time__extract_month + , subq_5.metric_time__extract_day + , subq_5.metric_time__extract_dow + , subq_5.metric_time__extract_doy + , subq_5.customer_id + , subq_5.customer_name + , subq_5.customer_atomic_weight + , subq_5.customer_id__customer_name + , subq_5.customer_id__customer_atomic_weight FROM ( -- Metric Time Dimension 'ds_partitioned' SELECT - subq_5.ds_partitioned__day - , subq_5.ds_partitioned__week - , subq_5.ds_partitioned__month - , subq_5.ds_partitioned__quarter - , subq_5.ds_partitioned__year - , subq_5.ds_partitioned__extract_year - , subq_5.ds_partitioned__extract_quarter - , subq_5.ds_partitioned__extract_month - , subq_5.ds_partitioned__extract_day - , subq_5.ds_partitioned__extract_dow - , subq_5.ds_partitioned__extract_doy - , subq_5.customer_id__ds_partitioned__day - , subq_5.customer_id__ds_partitioned__week - , subq_5.customer_id__ds_partitioned__month - , subq_5.customer_id__ds_partitioned__quarter - , subq_5.customer_id__ds_partitioned__year - , subq_5.customer_id__ds_partitioned__extract_year - , subq_5.customer_id__ds_partitioned__extract_quarter - , subq_5.customer_id__ds_partitioned__extract_month - , subq_5.customer_id__ds_partitioned__extract_day - , subq_5.customer_id__ds_partitioned__extract_dow - , subq_5.customer_id__ds_partitioned__extract_doy - , subq_5.ds_partitioned__day AS metric_time__day - , subq_5.ds_partitioned__week AS metric_time__week - , subq_5.ds_partitioned__month AS metric_time__month - , subq_5.ds_partitioned__quarter AS metric_time__quarter - , subq_5.ds_partitioned__year AS metric_time__year - , subq_5.ds_partitioned__extract_year AS metric_time__extract_year - , subq_5.ds_partitioned__extract_quarter AS metric_time__extract_quarter - , subq_5.ds_partitioned__extract_month AS metric_time__extract_month - , subq_5.ds_partitioned__extract_day AS metric_time__extract_day - , subq_5.ds_partitioned__extract_dow AS metric_time__extract_dow - , subq_5.ds_partitioned__extract_doy AS metric_time__extract_doy - , subq_5.customer_id - , subq_5.customer_name - , subq_5.customer_atomic_weight - , subq_5.customer_id__customer_name - , subq_5.customer_id__customer_atomic_weight - , subq_5.customers + 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.ds_partitioned__day AS metric_time__day + , subq_4.ds_partitioned__week AS metric_time__week + , subq_4.ds_partitioned__month AS metric_time__month + , subq_4.ds_partitioned__quarter AS metric_time__quarter + , subq_4.ds_partitioned__year AS metric_time__year + , subq_4.ds_partitioned__extract_year AS metric_time__extract_year + , subq_4.ds_partitioned__extract_quarter AS metric_time__extract_quarter + , subq_4.ds_partitioned__extract_month AS metric_time__extract_month + , subq_4.ds_partitioned__extract_day AS metric_time__extract_day + , subq_4.ds_partitioned__extract_dow AS metric_time__extract_dow + , subq_4.ds_partitioned__extract_doy AS metric_time__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_4.customers FROM ( -- Read Elements From Semantic Model 'customer_table' SELECT @@ -487,25 +536,25 @@ FROM ( , EXTRACT(doy FROM customer_table_src_22000.ds_partitioned) AS customer_id__ds_partitioned__extract_doy , customer_table_src_22000.customer_id FROM ***************************.customer_table customer_table_src_22000 - ) subq_5 - ) subq_6 - ) subq_7 + ) subq_4 + ) subq_5 + ) subq_6 ON ( - subq_4.customer_id = subq_7.customer_id + subq_3.customer_id = subq_6.customer_id ) AND ( - subq_4.ds_partitioned__day = subq_7.ds_partitioned__day + subq_3.ds_partitioned__day = subq_6.ds_partitioned__day ) - ) subq_8 - ) subq_9 + ) subq_7 + ) subq_8 ON ( - subq_2.account_id = subq_9.account_id + subq_1.account_id = subq_8.account_id ) AND ( - subq_2.ds_partitioned__day = subq_9.ds_partitioned__day + subq_1.ds_partitioned__day = subq_8.ds_partitioned__day ) - ) subq_10 - ) subq_11 + ) subq_9 + ) subq_10 GROUP BY - subq_11.account_id__customer_id__customer_name -) subq_12 + subq_10.account_id__customer_id__customer_name +) subq_11 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql index 13473156ca..d59e00bb74 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_multihop_node__plan0_optimized.sql @@ -3,7 +3,7 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.customer_id__customer_name AS account_id__customer_id__customer_name + subq_20.customer_id__customer_name AS account_id__customer_id__customer_name , SUM(account_month_txns_src_22000.txn_count) AS txn_count FROM ***************************.account_month_txns account_month_txns_src_22000 LEFT OUTER JOIN ( @@ -22,12 +22,12 @@ LEFT OUTER JOIN ( ) AND ( DATE_TRUNC('day', bridge_table_src_22000.ds_partitioned) = DATE_TRUNC('day', customer_table_src_22000.ds_partitioned) ) -) subq_22 +) subq_20 ON ( - account_month_txns_src_22000.account_id = subq_22.account_id + account_month_txns_src_22000.account_id = subq_20.account_id ) AND ( - DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_22.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_22000.ds_partitioned) = subq_20.ds_partitioned__day ) GROUP BY - subq_22.customer_id__customer_name + subq_20.customer_id__customer_name diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0.sql index 5b3083b605..0f2ad78f0f 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0.sql @@ -1,24 +1,162 @@ -- Compute Metrics via Expressions SELECT - subq_7.total_account_balance_first_day_of_month + subq_6.total_account_balance_first_day_of_month FROM ( -- Aggregate Measures SELECT - SUM(subq_6.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_5.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Pass Only Elements: ['total_account_balance_first_day_of_month',] SELECT - subq_5.total_account_balance_first_day_of_month + subq_4.total_account_balance_first_day_of_month FROM ( -- Join on MIN(ds_month) and [] grouping by None SELECT - subq_2.ds_month__month AS ds_month__month - , subq_2.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month + 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_month__month AS ds_month__month + , subq_1.ds_month__quarter AS ds_month__quarter + , subq_1.ds_month__year AS ds_month__year + , subq_1.ds_month__extract_year AS ds_month__extract_year + , subq_1.ds_month__extract_quarter AS ds_month__extract_quarter + , subq_1.ds_month__extract_month AS ds_month__extract_month + , subq_1.account__ds__day AS account__ds__day + , subq_1.account__ds__week AS account__ds__week + , subq_1.account__ds__month AS account__ds__month + , subq_1.account__ds__quarter AS account__ds__quarter + , subq_1.account__ds__year AS account__ds__year + , subq_1.account__ds__extract_year AS account__ds__extract_year + , subq_1.account__ds__extract_quarter AS account__ds__extract_quarter + , subq_1.account__ds__extract_month AS account__ds__extract_month + , subq_1.account__ds__extract_day AS account__ds__extract_day + , subq_1.account__ds__extract_dow AS account__ds__extract_dow + , subq_1.account__ds__extract_doy AS account__ds__extract_doy + , subq_1.account__ds_month__month AS account__ds_month__month + , subq_1.account__ds_month__quarter AS account__ds_month__quarter + , subq_1.account__ds_month__year AS account__ds_month__year + , subq_1.account__ds_month__extract_year AS account__ds_month__extract_year + , subq_1.account__ds_month__extract_quarter AS account__ds_month__extract_quarter + , subq_1.account__ds_month__extract_month AS account__ds_month__extract_month + , 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.user AS user + , subq_1.account__user AS account__user + , subq_1.account_type AS account_type + , subq_1.account__account_type AS account__account_type + , subq_1.total_account_balance_first_day_of_month AS total_account_balance_first_day_of_month FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] + -- Metric Time Dimension 'ds_month' SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_month__month + , subq_0.ds_month__quarter + , subq_0.ds_month__year + , subq_0.ds_month__extract_year + , subq_0.ds_month__extract_quarter + , subq_0.ds_month__extract_month + , subq_0.account__ds__day + , subq_0.account__ds__week + , subq_0.account__ds__month + , subq_0.account__ds__quarter + , subq_0.account__ds__year + , subq_0.account__ds__extract_year + , subq_0.account__ds__extract_quarter + , subq_0.account__ds__extract_month + , subq_0.account__ds__extract_day + , subq_0.account__ds__extract_dow + , subq_0.account__ds__extract_doy + , subq_0.account__ds_month__month + , subq_0.account__ds_month__quarter + , subq_0.account__ds_month__year + , subq_0.account__ds_month__extract_year + , subq_0.account__ds_month__extract_quarter + , subq_0.account__ds_month__extract_month + , subq_0.ds_month__month AS metric_time__month + , subq_0.ds_month__quarter AS metric_time__quarter + , subq_0.ds_month__year AS metric_time__year + , subq_0.ds_month__extract_year AS metric_time__extract_year + , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter + , subq_0.ds_month__extract_month AS metric_time__extract_month + , subq_0.user + , subq_0.account__user + , subq_0.account_type + , subq_0.account__account_type + , subq_0.total_account_balance_first_day_of_month + FROM ( + -- Read Elements From Semantic Model 'accounts_source' + SELECT + accounts_source_src_28000.account_balance + , accounts_source_src_28000.account_balance AS total_account_balance_first_day + , accounts_source_src_28000.account_balance AS current_account_balance_by_user + , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM accounts_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month + , accounts_source_src_28000.account_type + , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day + , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week + , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year + , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month + , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM accounts_source_src_28000.ds) AS account__ds__extract_dow + , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy + , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month + , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter + , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year + , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year + , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter + , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month + , accounts_source_src_28000.account_type AS account__account_type + , accounts_source_src_28000.user_id AS user + , accounts_source_src_28000.user_id AS account__user + FROM ***************************.fct_accounts accounts_source_src_28000 + ) subq_0 + ) subq_1 + INNER JOIN ( + -- Filter row on MIN(ds_month__month) + SELECT + MIN(subq_2.ds_month__month) AS ds_month__month__complete FROM ( -- Metric Time Dimension 'ds_month' SELECT @@ -114,117 +252,10 @@ FROM ( , accounts_source_src_28000.user_id AS account__user FROM ***************************.fct_accounts accounts_source_src_28000 ) subq_0 - ) subq_1 - ) subq_2 - INNER JOIN ( - -- Filter row on MIN(ds_month__month) - SELECT - MIN(subq_3.ds_month__month) AS ds_month__month__complete - FROM ( - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] - SELECT - subq_1.ds_month__month - , subq_1.total_account_balance_first_day_of_month - FROM ( - -- Metric Time Dimension 'ds_month' - SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_month__month - , subq_0.ds_month__quarter - , subq_0.ds_month__year - , subq_0.ds_month__extract_year - , subq_0.ds_month__extract_quarter - , subq_0.ds_month__extract_month - , subq_0.account__ds__day - , subq_0.account__ds__week - , subq_0.account__ds__month - , subq_0.account__ds__quarter - , subq_0.account__ds__year - , subq_0.account__ds__extract_year - , subq_0.account__ds__extract_quarter - , subq_0.account__ds__extract_month - , subq_0.account__ds__extract_day - , subq_0.account__ds__extract_dow - , subq_0.account__ds__extract_doy - , subq_0.account__ds_month__month - , subq_0.account__ds_month__quarter - , subq_0.account__ds_month__year - , subq_0.account__ds_month__extract_year - , subq_0.account__ds_month__extract_quarter - , subq_0.account__ds_month__extract_month - , subq_0.ds_month__month AS metric_time__month - , subq_0.ds_month__quarter AS metric_time__quarter - , subq_0.ds_month__year AS metric_time__year - , subq_0.ds_month__extract_year AS metric_time__extract_year - , subq_0.ds_month__extract_quarter AS metric_time__extract_quarter - , subq_0.ds_month__extract_month AS metric_time__extract_month - , subq_0.user - , subq_0.account__user - , subq_0.account_type - , subq_0.account__account_type - , subq_0.total_account_balance_first_day_of_month - FROM ( - -- Read Elements From Semantic Model 'accounts_source' - SELECT - accounts_source_src_28000.account_balance - , accounts_source_src_28000.account_balance AS total_account_balance_first_day - , accounts_source_src_28000.account_balance AS current_account_balance_by_user - , accounts_source_src_28000.account_balance AS total_account_balance_first_day_of_month - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM accounts_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS ds_month__extract_month - , accounts_source_src_28000.account_type - , DATE_TRUNC('day', accounts_source_src_28000.ds) AS account__ds__day - , DATE_TRUNC('week', accounts_source_src_28000.ds) AS account__ds__week - , DATE_TRUNC('month', accounts_source_src_28000.ds) AS account__ds__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds) AS account__ds__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds) AS account__ds__year - , EXTRACT(year FROM accounts_source_src_28000.ds) AS account__ds__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds) AS account__ds__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds) AS account__ds__extract_month - , EXTRACT(day FROM accounts_source_src_28000.ds) AS account__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM accounts_source_src_28000.ds) AS account__ds__extract_dow - , EXTRACT(doy FROM accounts_source_src_28000.ds) AS account__ds__extract_doy - , DATE_TRUNC('month', accounts_source_src_28000.ds_month) AS account__ds_month__month - , DATE_TRUNC('quarter', accounts_source_src_28000.ds_month) AS account__ds_month__quarter - , DATE_TRUNC('year', accounts_source_src_28000.ds_month) AS account__ds_month__year - , EXTRACT(year FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_year - , EXTRACT(quarter FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_quarter - , EXTRACT(month FROM accounts_source_src_28000.ds_month) AS account__ds_month__extract_month - , accounts_source_src_28000.account_type AS account__account_type - , accounts_source_src_28000.user_id AS user - , accounts_source_src_28000.user_id AS account__user - FROM ***************************.fct_accounts accounts_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 ON - subq_2.ds_month__month = subq_4.ds_month__month__complete - ) subq_5 - ) subq_6 -) subq_7 + subq_1.ds_month__month = subq_3.ds_month__month__complete + ) subq_4 + ) subq_5 +) subq_6 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql index 90b981493f..93ae8752df 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_non_additive_dimension_with_non_default_grain__plan0_optimized.sql @@ -3,24 +3,22 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - SUM(subq_10.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month + SUM(subq_8.total_account_balance_first_day_of_month) AS total_account_balance_first_day_of_month FROM ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] SELECT DATE_TRUNC('month', ds_month) AS ds_month__month , account_balance AS total_account_balance_first_day_of_month FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_10 +) subq_8 INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Metric Time Dimension 'ds_month' - -- Pass Only Elements: ['total_account_balance_first_day_of_month', 'ds_month__month'] -- Filter row on MIN(ds_month__month) SELECT MIN(DATE_TRUNC('month', ds_month)) AS ds_month__month__complete FROM ***************************.fct_accounts accounts_source_src_28000 -) subq_12 +) subq_10 ON - subq_10.ds_month__month = subq_12.ds_month__month__complete + subq_8.ds_month__month = subq_10.ds_month__month__complete diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql index 20a2c516fb..b162d7ed62 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0.sql @@ -1,350 +1,401 @@ -- Compute Metrics via Expressions SELECT - subq_8.user__home_state - , subq_8.identity_verifications + subq_7.user__home_state + , subq_7.identity_verifications FROM ( -- Aggregate Measures SELECT - subq_7.user__home_state - , SUM(subq_7.identity_verifications) AS identity_verifications + subq_6.user__home_state + , SUM(subq_6.identity_verifications) AS identity_verifications FROM ( -- Pass Only Elements: ['identity_verifications', 'user__home_state'] SELECT - subq_6.user__home_state - , subq_6.identity_verifications + subq_5.user__home_state + , subq_5.identity_verifications FROM ( -- Join Standard Outputs SELECT - subq_5.home_state AS user__home_state - , subq_5.ds_partitioned__day AS user__ds_partitioned__day - , subq_2.ds_partitioned__day AS ds_partitioned__day - , subq_2.user AS user - , subq_2.identity_verifications AS identity_verifications + subq_4.home_state AS user__home_state + , subq_4.ds_partitioned__day AS user__ds_partitioned__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.verification__ds__day AS verification__ds__day + , subq_1.verification__ds__week AS verification__ds__week + , subq_1.verification__ds__month AS verification__ds__month + , subq_1.verification__ds__quarter AS verification__ds__quarter + , subq_1.verification__ds__year AS verification__ds__year + , subq_1.verification__ds__extract_year AS verification__ds__extract_year + , subq_1.verification__ds__extract_quarter AS verification__ds__extract_quarter + , subq_1.verification__ds__extract_month AS verification__ds__extract_month + , subq_1.verification__ds__extract_day AS verification__ds__extract_day + , subq_1.verification__ds__extract_dow AS verification__ds__extract_dow + , subq_1.verification__ds__extract_doy AS verification__ds__extract_doy + , subq_1.verification__ds_partitioned__day AS verification__ds_partitioned__day + , subq_1.verification__ds_partitioned__week AS verification__ds_partitioned__week + , subq_1.verification__ds_partitioned__month AS verification__ds_partitioned__month + , subq_1.verification__ds_partitioned__quarter AS verification__ds_partitioned__quarter + , subq_1.verification__ds_partitioned__year AS verification__ds_partitioned__year + , subq_1.verification__ds_partitioned__extract_year AS verification__ds_partitioned__extract_year + , subq_1.verification__ds_partitioned__extract_quarter AS verification__ds_partitioned__extract_quarter + , subq_1.verification__ds_partitioned__extract_month AS verification__ds_partitioned__extract_month + , subq_1.verification__ds_partitioned__extract_day AS verification__ds_partitioned__extract_day + , subq_1.verification__ds_partitioned__extract_dow AS verification__ds_partitioned__extract_dow + , subq_1.verification__ds_partitioned__extract_doy AS verification__ds_partitioned__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.verification AS verification + , subq_1.user AS user + , subq_1.verification__user AS verification__user + , subq_1.verification_type AS verification_type + , subq_1.verification__verification_type AS verification__verification_type + , subq_1.identity_verifications AS identity_verifications FROM ( - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] + -- Metric Time Dimension 'ds' SELECT - subq_1.ds_partitioned__day - , subq_1.user - , subq_1.identity_verifications + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.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 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'id_verifications' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.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 - FROM ( - -- Read Elements From Semantic Model 'id_verifications' - SELECT - 1 AS identity_verifications - , 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_0 - ) subq_1 - ) subq_2 + 1 AS identity_verifications + , 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_0 + ) subq_1 LEFT OUTER JOIN ( -- Pass Only Elements: ['home_state', 'ds_partitioned__day', 'user'] SELECT - subq_4.ds_partitioned__day - , subq_4.user - , subq_4.home_state + subq_3.ds_partitioned__day + , subq_3.user + , subq_3.home_state FROM ( -- Metric Time Dimension 'created_at' 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.ds_partitioned__day - , subq_3.ds_partitioned__week - , subq_3.ds_partitioned__month - , subq_3.ds_partitioned__quarter - , subq_3.ds_partitioned__year - , subq_3.ds_partitioned__extract_year - , subq_3.ds_partitioned__extract_quarter - , subq_3.ds_partitioned__extract_month - , subq_3.ds_partitioned__extract_day - , subq_3.ds_partitioned__extract_dow - , subq_3.ds_partitioned__extract_doy - , subq_3.last_profile_edit_ts__millisecond - , subq_3.last_profile_edit_ts__second - , subq_3.last_profile_edit_ts__minute - , subq_3.last_profile_edit_ts__hour - , subq_3.last_profile_edit_ts__day - , subq_3.last_profile_edit_ts__week - , subq_3.last_profile_edit_ts__month - , subq_3.last_profile_edit_ts__quarter - , subq_3.last_profile_edit_ts__year - , subq_3.last_profile_edit_ts__extract_year - , subq_3.last_profile_edit_ts__extract_quarter - , subq_3.last_profile_edit_ts__extract_month - , subq_3.last_profile_edit_ts__extract_day - , subq_3.last_profile_edit_ts__extract_dow - , subq_3.last_profile_edit_ts__extract_doy - , subq_3.bio_added_ts__second - , subq_3.bio_added_ts__minute - , subq_3.bio_added_ts__hour - , subq_3.bio_added_ts__day - , subq_3.bio_added_ts__week - , subq_3.bio_added_ts__month - , subq_3.bio_added_ts__quarter - , subq_3.bio_added_ts__year - , subq_3.bio_added_ts__extract_year - , subq_3.bio_added_ts__extract_quarter - , subq_3.bio_added_ts__extract_month - , subq_3.bio_added_ts__extract_day - , subq_3.bio_added_ts__extract_dow - , subq_3.bio_added_ts__extract_doy - , subq_3.last_login_ts__minute - , subq_3.last_login_ts__hour - , subq_3.last_login_ts__day - , subq_3.last_login_ts__week - , subq_3.last_login_ts__month - , subq_3.last_login_ts__quarter - , subq_3.last_login_ts__year - , subq_3.last_login_ts__extract_year - , subq_3.last_login_ts__extract_quarter - , subq_3.last_login_ts__extract_month - , subq_3.last_login_ts__extract_day - , subq_3.last_login_ts__extract_dow - , subq_3.last_login_ts__extract_doy - , subq_3.archived_at__hour - , subq_3.archived_at__day - , subq_3.archived_at__week - , subq_3.archived_at__month - , subq_3.archived_at__quarter - , subq_3.archived_at__year - , subq_3.archived_at__extract_year - , subq_3.archived_at__extract_quarter - , subq_3.archived_at__extract_month - , subq_3.archived_at__extract_day - , subq_3.archived_at__extract_dow - , subq_3.archived_at__extract_doy - , subq_3.user__ds__day - , subq_3.user__ds__week - , subq_3.user__ds__month - , subq_3.user__ds__quarter - , subq_3.user__ds__year - , subq_3.user__ds__extract_year - , subq_3.user__ds__extract_quarter - , subq_3.user__ds__extract_month - , subq_3.user__ds__extract_day - , subq_3.user__ds__extract_dow - , subq_3.user__ds__extract_doy - , subq_3.user__created_at__day - , subq_3.user__created_at__week - , subq_3.user__created_at__month - , subq_3.user__created_at__quarter - , subq_3.user__created_at__year - , subq_3.user__created_at__extract_year - , subq_3.user__created_at__extract_quarter - , subq_3.user__created_at__extract_month - , subq_3.user__created_at__extract_day - , subq_3.user__created_at__extract_dow - , subq_3.user__created_at__extract_doy - , subq_3.user__ds_partitioned__day - , subq_3.user__ds_partitioned__week - , subq_3.user__ds_partitioned__month - , subq_3.user__ds_partitioned__quarter - , subq_3.user__ds_partitioned__year - , subq_3.user__ds_partitioned__extract_year - , subq_3.user__ds_partitioned__extract_quarter - , subq_3.user__ds_partitioned__extract_month - , subq_3.user__ds_partitioned__extract_day - , subq_3.user__ds_partitioned__extract_dow - , subq_3.user__ds_partitioned__extract_doy - , subq_3.user__last_profile_edit_ts__millisecond - , subq_3.user__last_profile_edit_ts__second - , subq_3.user__last_profile_edit_ts__minute - , subq_3.user__last_profile_edit_ts__hour - , subq_3.user__last_profile_edit_ts__day - , subq_3.user__last_profile_edit_ts__week - , subq_3.user__last_profile_edit_ts__month - , subq_3.user__last_profile_edit_ts__quarter - , subq_3.user__last_profile_edit_ts__year - , subq_3.user__last_profile_edit_ts__extract_year - , subq_3.user__last_profile_edit_ts__extract_quarter - , subq_3.user__last_profile_edit_ts__extract_month - , subq_3.user__last_profile_edit_ts__extract_day - , subq_3.user__last_profile_edit_ts__extract_dow - , subq_3.user__last_profile_edit_ts__extract_doy - , subq_3.user__bio_added_ts__second - , subq_3.user__bio_added_ts__minute - , subq_3.user__bio_added_ts__hour - , subq_3.user__bio_added_ts__day - , subq_3.user__bio_added_ts__week - , subq_3.user__bio_added_ts__month - , subq_3.user__bio_added_ts__quarter - , subq_3.user__bio_added_ts__year - , subq_3.user__bio_added_ts__extract_year - , subq_3.user__bio_added_ts__extract_quarter - , subq_3.user__bio_added_ts__extract_month - , subq_3.user__bio_added_ts__extract_day - , subq_3.user__bio_added_ts__extract_dow - , subq_3.user__bio_added_ts__extract_doy - , subq_3.user__last_login_ts__minute - , subq_3.user__last_login_ts__hour - , subq_3.user__last_login_ts__day - , subq_3.user__last_login_ts__week - , subq_3.user__last_login_ts__month - , subq_3.user__last_login_ts__quarter - , subq_3.user__last_login_ts__year - , subq_3.user__last_login_ts__extract_year - , subq_3.user__last_login_ts__extract_quarter - , subq_3.user__last_login_ts__extract_month - , subq_3.user__last_login_ts__extract_day - , subq_3.user__last_login_ts__extract_dow - , subq_3.user__last_login_ts__extract_doy - , subq_3.user__archived_at__hour - , subq_3.user__archived_at__day - , subq_3.user__archived_at__week - , subq_3.user__archived_at__month - , subq_3.user__archived_at__quarter - , subq_3.user__archived_at__year - , subq_3.user__archived_at__extract_year - , subq_3.user__archived_at__extract_quarter - , subq_3.user__archived_at__extract_month - , subq_3.user__archived_at__extract_day - , subq_3.user__archived_at__extract_dow - , subq_3.user__archived_at__extract_doy - , subq_3.created_at__day AS metric_time__day - , subq_3.created_at__week AS metric_time__week - , subq_3.created_at__month AS metric_time__month - , subq_3.created_at__quarter AS metric_time__quarter - , subq_3.created_at__year AS metric_time__year - , subq_3.created_at__extract_year AS metric_time__extract_year - , subq_3.created_at__extract_quarter AS metric_time__extract_quarter - , subq_3.created_at__extract_month AS metric_time__extract_month - , subq_3.created_at__extract_day AS metric_time__extract_day - , subq_3.created_at__extract_dow AS metric_time__extract_dow - , subq_3.created_at__extract_doy AS metric_time__extract_doy - , subq_3.user - , subq_3.home_state - , subq_3.user__home_state - , subq_3.new_users + subq_2.ds__day + , subq_2.ds__week + , subq_2.ds__month + , subq_2.ds__quarter + , subq_2.ds__year + , subq_2.ds__extract_year + , subq_2.ds__extract_quarter + , subq_2.ds__extract_month + , subq_2.ds__extract_day + , subq_2.ds__extract_dow + , subq_2.ds__extract_doy + , subq_2.created_at__day + , subq_2.created_at__week + , subq_2.created_at__month + , subq_2.created_at__quarter + , subq_2.created_at__year + , subq_2.created_at__extract_year + , subq_2.created_at__extract_quarter + , subq_2.created_at__extract_month + , subq_2.created_at__extract_day + , subq_2.created_at__extract_dow + , subq_2.created_at__extract_doy + , subq_2.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.last_profile_edit_ts__millisecond + , subq_2.last_profile_edit_ts__second + , subq_2.last_profile_edit_ts__minute + , subq_2.last_profile_edit_ts__hour + , subq_2.last_profile_edit_ts__day + , subq_2.last_profile_edit_ts__week + , subq_2.last_profile_edit_ts__month + , subq_2.last_profile_edit_ts__quarter + , subq_2.last_profile_edit_ts__year + , subq_2.last_profile_edit_ts__extract_year + , subq_2.last_profile_edit_ts__extract_quarter + , subq_2.last_profile_edit_ts__extract_month + , subq_2.last_profile_edit_ts__extract_day + , subq_2.last_profile_edit_ts__extract_dow + , subq_2.last_profile_edit_ts__extract_doy + , subq_2.bio_added_ts__second + , subq_2.bio_added_ts__minute + , subq_2.bio_added_ts__hour + , subq_2.bio_added_ts__day + , subq_2.bio_added_ts__week + , subq_2.bio_added_ts__month + , subq_2.bio_added_ts__quarter + , subq_2.bio_added_ts__year + , subq_2.bio_added_ts__extract_year + , subq_2.bio_added_ts__extract_quarter + , subq_2.bio_added_ts__extract_month + , subq_2.bio_added_ts__extract_day + , subq_2.bio_added_ts__extract_dow + , subq_2.bio_added_ts__extract_doy + , subq_2.last_login_ts__minute + , subq_2.last_login_ts__hour + , subq_2.last_login_ts__day + , subq_2.last_login_ts__week + , subq_2.last_login_ts__month + , subq_2.last_login_ts__quarter + , subq_2.last_login_ts__year + , subq_2.last_login_ts__extract_year + , subq_2.last_login_ts__extract_quarter + , subq_2.last_login_ts__extract_month + , subq_2.last_login_ts__extract_day + , subq_2.last_login_ts__extract_dow + , subq_2.last_login_ts__extract_doy + , subq_2.archived_at__hour + , subq_2.archived_at__day + , subq_2.archived_at__week + , subq_2.archived_at__month + , subq_2.archived_at__quarter + , subq_2.archived_at__year + , subq_2.archived_at__extract_year + , subq_2.archived_at__extract_quarter + , subq_2.archived_at__extract_month + , subq_2.archived_at__extract_day + , subq_2.archived_at__extract_dow + , subq_2.archived_at__extract_doy + , subq_2.user__ds__day + , subq_2.user__ds__week + , subq_2.user__ds__month + , subq_2.user__ds__quarter + , subq_2.user__ds__year + , subq_2.user__ds__extract_year + , subq_2.user__ds__extract_quarter + , subq_2.user__ds__extract_month + , subq_2.user__ds__extract_day + , subq_2.user__ds__extract_dow + , subq_2.user__ds__extract_doy + , subq_2.user__created_at__day + , subq_2.user__created_at__week + , subq_2.user__created_at__month + , subq_2.user__created_at__quarter + , subq_2.user__created_at__year + , subq_2.user__created_at__extract_year + , subq_2.user__created_at__extract_quarter + , subq_2.user__created_at__extract_month + , subq_2.user__created_at__extract_day + , subq_2.user__created_at__extract_dow + , subq_2.user__created_at__extract_doy + , subq_2.user__ds_partitioned__day + , subq_2.user__ds_partitioned__week + , subq_2.user__ds_partitioned__month + , subq_2.user__ds_partitioned__quarter + , subq_2.user__ds_partitioned__year + , subq_2.user__ds_partitioned__extract_year + , subq_2.user__ds_partitioned__extract_quarter + , subq_2.user__ds_partitioned__extract_month + , subq_2.user__ds_partitioned__extract_day + , subq_2.user__ds_partitioned__extract_dow + , subq_2.user__ds_partitioned__extract_doy + , subq_2.user__last_profile_edit_ts__millisecond + , subq_2.user__last_profile_edit_ts__second + , subq_2.user__last_profile_edit_ts__minute + , subq_2.user__last_profile_edit_ts__hour + , subq_2.user__last_profile_edit_ts__day + , subq_2.user__last_profile_edit_ts__week + , subq_2.user__last_profile_edit_ts__month + , subq_2.user__last_profile_edit_ts__quarter + , subq_2.user__last_profile_edit_ts__year + , subq_2.user__last_profile_edit_ts__extract_year + , subq_2.user__last_profile_edit_ts__extract_quarter + , subq_2.user__last_profile_edit_ts__extract_month + , subq_2.user__last_profile_edit_ts__extract_day + , subq_2.user__last_profile_edit_ts__extract_dow + , subq_2.user__last_profile_edit_ts__extract_doy + , subq_2.user__bio_added_ts__second + , subq_2.user__bio_added_ts__minute + , subq_2.user__bio_added_ts__hour + , subq_2.user__bio_added_ts__day + , subq_2.user__bio_added_ts__week + , subq_2.user__bio_added_ts__month + , subq_2.user__bio_added_ts__quarter + , subq_2.user__bio_added_ts__year + , subq_2.user__bio_added_ts__extract_year + , subq_2.user__bio_added_ts__extract_quarter + , subq_2.user__bio_added_ts__extract_month + , subq_2.user__bio_added_ts__extract_day + , subq_2.user__bio_added_ts__extract_dow + , subq_2.user__bio_added_ts__extract_doy + , subq_2.user__last_login_ts__minute + , subq_2.user__last_login_ts__hour + , subq_2.user__last_login_ts__day + , subq_2.user__last_login_ts__week + , subq_2.user__last_login_ts__month + , subq_2.user__last_login_ts__quarter + , subq_2.user__last_login_ts__year + , subq_2.user__last_login_ts__extract_year + , subq_2.user__last_login_ts__extract_quarter + , subq_2.user__last_login_ts__extract_month + , subq_2.user__last_login_ts__extract_day + , subq_2.user__last_login_ts__extract_dow + , subq_2.user__last_login_ts__extract_doy + , subq_2.user__archived_at__hour + , subq_2.user__archived_at__day + , subq_2.user__archived_at__week + , subq_2.user__archived_at__month + , subq_2.user__archived_at__quarter + , subq_2.user__archived_at__year + , subq_2.user__archived_at__extract_year + , subq_2.user__archived_at__extract_quarter + , subq_2.user__archived_at__extract_month + , subq_2.user__archived_at__extract_day + , subq_2.user__archived_at__extract_dow + , subq_2.user__archived_at__extract_doy + , subq_2.created_at__day AS metric_time__day + , subq_2.created_at__week AS metric_time__week + , subq_2.created_at__month AS metric_time__month + , subq_2.created_at__quarter AS metric_time__quarter + , subq_2.created_at__year AS metric_time__year + , subq_2.created_at__extract_year AS metric_time__extract_year + , subq_2.created_at__extract_quarter AS metric_time__extract_quarter + , subq_2.created_at__extract_month AS metric_time__extract_month + , subq_2.created_at__extract_day AS metric_time__extract_day + , subq_2.created_at__extract_dow AS metric_time__extract_dow + , subq_2.created_at__extract_doy AS metric_time__extract_doy + , subq_2.user + , subq_2.home_state + , subq_2.user__home_state + , subq_2.new_users FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT @@ -528,17 +579,17 @@ FROM ( , EXTRACT(doy FROM users_ds_source_src_28000.archived_at) AS user__archived_at__extract_doy , users_ds_source_src_28000.user_id AS user FROM ***************************.dim_users users_ds_source_src_28000 - ) subq_3 - ) subq_4 - ) subq_5 + ) subq_2 + ) subq_3 + ) subq_4 ON ( - subq_2.user = subq_5.user + subq_1.user = subq_4.user ) AND ( - subq_2.ds_partitioned__day = subq_5.ds_partitioned__day + subq_1.ds_partitioned__day = subq_4.ds_partitioned__day ) - ) subq_6 - ) subq_7 + ) subq_5 + ) subq_6 GROUP BY - subq_7.user__home_state -) subq_8 + subq_6.user__home_state +) subq_7 diff --git a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql index be2da473cc..abeac83bb7 100644 --- a/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_query_rendering.py/SqlQueryPlan/Trino/test_partitioned_join__plan0_optimized.sql @@ -4,24 +4,23 @@ -- Compute Metrics via Expressions SELECT users_ds_source_src_28000.home_state AS user__home_state - , SUM(subq_11.identity_verifications) AS identity_verifications + , SUM(subq_9.identity_verifications) AS identity_verifications FROM ( -- Read Elements From Semantic Model 'id_verifications' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_28000 -) subq_11 +) subq_9 LEFT OUTER JOIN ***************************.dim_users users_ds_source_src_28000 ON ( - subq_11.user = users_ds_source_src_28000.user_id + subq_9.user = users_ds_source_src_28000.user_id ) AND ( - subq_11.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) + subq_9.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_28000.ds_partitioned) ) GROUP BY users_ds_source_src_28000.home_state diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml index d44a1d8cc7..67e5db8a0e 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml @@ -15,7 +15,7 @@ - + @@ -31,37 +31,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + @@ -90,7 +78,7 @@ - + @@ -106,38 +94,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfpo_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfpo_0.xml index 3f01d31cea..b821e05b27 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfpo_0.xml @@ -14,7 +14,7 @@ - + @@ -31,39 +31,25 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - + diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml index 18bfed8f44..238803c349 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml @@ -45,7 +45,7 @@ - + @@ -95,33 +95,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml index efebedf93a..3d35474a45 100644 --- a/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml @@ -14,7 +14,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -95,33 +95,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 69036721c3..0134837077 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day , booking__is_instant - ) subq_5 + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 22fa76fdb7..6e87b4caae 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql index 75603754c5..bc55f9eed4 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day - , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week - , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month - , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month - , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter - , DATETIME_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 - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month - , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter - , DATETIME_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 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS paid_at__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds, day) AS booking__ds__day + , DATETIME_TRUNC(bookings_source_src_28000.ds, isoweek) AS booking__ds__week + , DATETIME_TRUNC(bookings_source_src_28000.ds, month) AS booking__ds__month + , DATETIME_TRUNC(bookings_source_src_28000.ds, quarter) AS booking__ds__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, day) AS booking__ds_partitioned__day + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, isoweek) AS booking__ds_partitioned__week + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, month) AS booking__ds_partitioned__month + , DATETIME_TRUNC(bookings_source_src_28000.ds_partitioned, quarter) AS booking__ds_partitioned__quarter + , DATETIME_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 + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, day) AS booking__paid_at__day + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, isoweek) AS booking__paid_at__week + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, month) AS booking__paid_at__month + , DATETIME_TRUNC(bookings_source_src_28000.paid_at, quarter) AS booking__paid_at__quarter + , DATETIME_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__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY metric_time__day - ) subq_5 + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 4ecdfebc25..391e7f7219 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 7945e559e4..8d611568f3 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 2b1b12de20..41be8cd7d5 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATETIME_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index edea181c6c..546a53c15c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - , subq_4.booking__is_instant - ) subq_5 + subq_3.metric_time__day + , subq_3.booking__is_instant + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 16b504c370..ed183f4066 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql index 10d71d6f54..5731ba5b46 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAYOFWEEK_ISO FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 1185bf668d..7db2cc2894 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index d60f9f75b1..46332b3996 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 476eccde2c..19f81cdd9b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index c9dbea49ef..ff338c3d62 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - , subq_4.booking__is_instant - ) subq_5 + subq_3.metric_time__day + , subq_3.booking__is_instant + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 16b504c370..ed183f4066 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql index a39da38b06..8eeaa11c1c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(isodow FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 1185bf668d..7db2cc2894 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index ed0bc69197..24f29ee530 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 476eccde2c..19f81cdd9b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 1f1e973b16..72081ddc87 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - , subq_4.booking__is_instant - ) subq_5 + subq_3.metric_time__day + , subq_3.booking__is_instant + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 16b504c370..ed183f4066 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql index fbbca501a8..eaa3a8eb4d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds) END AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.ds_partitioned) END AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , CASE WHEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) = 0 THEN EXTRACT(dow FROM bookings_source_src_28000.paid_at) + 7 ELSE EXTRACT(dow FROM bookings_source_src_28000.paid_at) END AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 1185bf668d..7db2cc2894 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 53e30fb806..a7407a95de 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 476eccde2c..19f81cdd9b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 0abd0417f8..95a63d3b6c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - , subq_4.booking__is_instant - ) subq_5 + subq_3.metric_time__day + , subq_3.booking__is_instant + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 16b504c370..ed183f4066 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql index 1841f75d94..6fda495f52 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(dayofweekiso FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 1185bf668d..7db2cc2894 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 06ba1452be..5adf4a22a0 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 476eccde2c..19f81cdd9b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql index 6d5948a510..758aa77872 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0.sql @@ -1,255 +1,341 @@ -- Compute Metrics via Expressions SELECT - subq_9.metric_time__day - , subq_9.booking__is_instant - , subq_9.bookings AS instant_bookings_with_measure_filter + subq_8.metric_time__day + , subq_8.booking__is_instant + , subq_8.bookings AS instant_bookings_with_measure_filter FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.booking__is_instant AS booking__is_instant - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.booking__is_instant AS booking__is_instant + , subq_4.bookings AS bookings FROM ( -- Filter Time Spine SELECT - subq_8.metric_time__day + subq_7.metric_time__day FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_8 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_7 WHERE metric_time__day > '2020-01-01' - ) subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , subq_4.booking__is_instant - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , subq_3.booking__is_instant + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.booking__is_instant - , subq_3.bookings + subq_2.metric_time__day + , subq_2.booking__is_instant + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.listing - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.listing - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - , subq_4.booking__is_instant - ) subq_5 + subq_3.metric_time__day + , subq_3.booking__is_instant + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_9 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_8 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql index 16b504c370..ed183f4066 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_input_measure_constraint__plan0_optimized.sql @@ -1,9 +1,9 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_16.metric_time__day AS metric_time__day - , subq_15.booking__is_instant AS booking__is_instant - , subq_15.bookings AS instant_bookings_with_measure_filter + subq_14.metric_time__day AS metric_time__day + , subq_13.booking__is_instant AS booking__is_instant + , subq_13.bookings AS instant_bookings_with_measure_filter FROM ( -- Filter Time Spine SELECT @@ -12,10 +12,10 @@ FROM ( -- Time Spine SELECT ds AS metric_time__day - FROM ***************************.mf_time_spine subq_17 - ) subq_18 + FROM ***************************.mf_time_spine subq_15 + ) subq_16 WHERE metric_time__day > '2020-01-01' -) subq_16 +) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -27,18 +27,17 @@ LEFT OUTER JOIN ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_12 + ) subq_10 WHERE ((booking__is_instant) AND (listing IS NOT NULL)) AND (metric_time__day > '2020-01-01') GROUP BY metric_time__day , booking__is_instant -) subq_15 +) subq_13 ON - subq_16.metric_time__day = subq_15.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql index 6c43edefe6..92115c5fd1 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -1,242 +1,330 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__day - , COALESCE(subq_8.bookings, 0) AS bookings_fill_nulls_with_0 + subq_7.metric_time__day + , COALESCE(subq_7.bookings, 0) AS bookings_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - subq_6.metric_time__day AS metric_time__day - , subq_5.bookings AS bookings + subq_5.metric_time__day AS metric_time__day + , subq_4.bookings AS bookings FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day - FROM ***************************.mf_time_spine subq_7 - ) subq_6 + subq_6.ds AS metric_time__day + FROM ***************************.mf_time_spine subq_6 + ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures SELECT - subq_4.metric_time__day - , SUM(subq_4.bookings) AS bookings + subq_3.metric_time__day + , SUM(subq_3.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_3.metric_time__day - , subq_3.bookings + subq_2.metric_time__day + , subq_2.bookings FROM ( -- Constrain Output with WHERE SELECT - subq_2.metric_time__day - , subq_2.booking__is_instant - , subq_2.bookings + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant + , subq_1.booking__is_instant + , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Metric Time Dimension 'ds' SELECT - subq_1.metric_time__day - , subq_1.booking__is_instant - , subq_1.bookings + subq_0.ds__day + , subq_0.ds__week + , subq_0.ds__month + , subq_0.ds__quarter + , subq_0.ds__year + , subq_0.ds__extract_year + , subq_0.ds__extract_quarter + , subq_0.ds__extract_month + , subq_0.ds__extract_day + , subq_0.ds__extract_dow + , subq_0.ds__extract_doy + , subq_0.ds_partitioned__day + , subq_0.ds_partitioned__week + , subq_0.ds_partitioned__month + , subq_0.ds_partitioned__quarter + , subq_0.ds_partitioned__year + , subq_0.ds_partitioned__extract_year + , subq_0.ds_partitioned__extract_quarter + , subq_0.ds_partitioned__extract_month + , subq_0.ds_partitioned__extract_day + , subq_0.ds_partitioned__extract_dow + , subq_0.ds_partitioned__extract_doy + , subq_0.paid_at__day + , subq_0.paid_at__week + , subq_0.paid_at__month + , subq_0.paid_at__quarter + , subq_0.paid_at__year + , subq_0.paid_at__extract_year + , subq_0.paid_at__extract_quarter + , subq_0.paid_at__extract_month + , subq_0.paid_at__extract_day + , subq_0.paid_at__extract_dow + , subq_0.paid_at__extract_doy + , subq_0.booking__ds__day + , subq_0.booking__ds__week + , subq_0.booking__ds__month + , subq_0.booking__ds__quarter + , subq_0.booking__ds__year + , subq_0.booking__ds__extract_year + , subq_0.booking__ds__extract_quarter + , subq_0.booking__ds__extract_month + , subq_0.booking__ds__extract_day + , subq_0.booking__ds__extract_dow + , subq_0.booking__ds__extract_doy + , subq_0.booking__ds_partitioned__day + , subq_0.booking__ds_partitioned__week + , subq_0.booking__ds_partitioned__month + , subq_0.booking__ds_partitioned__quarter + , subq_0.booking__ds_partitioned__year + , subq_0.booking__ds_partitioned__extract_year + , subq_0.booking__ds_partitioned__extract_quarter + , subq_0.booking__ds_partitioned__extract_month + , subq_0.booking__ds_partitioned__extract_day + , subq_0.booking__ds_partitioned__extract_dow + , subq_0.booking__ds_partitioned__extract_doy + , subq_0.booking__paid_at__day + , subq_0.booking__paid_at__week + , subq_0.booking__paid_at__month + , subq_0.booking__paid_at__quarter + , subq_0.booking__paid_at__year + , subq_0.booking__paid_at__extract_year + , subq_0.booking__paid_at__extract_quarter + , subq_0.booking__paid_at__extract_month + , subq_0.booking__paid_at__extract_day + , subq_0.booking__paid_at__extract_dow + , subq_0.booking__paid_at__extract_doy + , subq_0.ds__day AS metric_time__day + , subq_0.ds__week AS metric_time__week + , subq_0.ds__month AS metric_time__month + , subq_0.ds__quarter AS metric_time__quarter + , subq_0.ds__year AS metric_time__year + , subq_0.ds__extract_year AS metric_time__extract_year + , subq_0.ds__extract_quarter AS metric_time__extract_quarter + , subq_0.ds__extract_month AS metric_time__extract_month + , subq_0.ds__extract_day AS metric_time__extract_day + , subq_0.ds__extract_dow AS metric_time__extract_dow + , subq_0.ds__extract_doy AS metric_time__extract_doy + , subq_0.listing + , subq_0.guest + , subq_0.host + , subq_0.booking__listing + , subq_0.booking__guest + , subq_0.booking__host + , subq_0.is_instant + , subq_0.booking__is_instant + , subq_0.bookings + , subq_0.instant_bookings + , subq_0.booking_value + , subq_0.max_booking_value + , subq_0.min_booking_value + , subq_0.bookers + , subq_0.average_booking_value + , subq_0.referred_bookings + , subq_0.median_booking_value + , subq_0.booking_value_p99 + , subq_0.discrete_booking_value_p99 + , subq_0.approximate_continuous_booking_value_p99 + , subq_0.approximate_discrete_booking_value_p99 FROM ( - -- Metric Time Dimension 'ds' + -- Read Elements From Semantic Model 'bookings_source' SELECT - subq_0.ds__day - , subq_0.ds__week - , subq_0.ds__month - , subq_0.ds__quarter - , subq_0.ds__year - , subq_0.ds__extract_year - , subq_0.ds__extract_quarter - , subq_0.ds__extract_month - , subq_0.ds__extract_day - , subq_0.ds__extract_dow - , subq_0.ds__extract_doy - , subq_0.ds_partitioned__day - , subq_0.ds_partitioned__week - , subq_0.ds_partitioned__month - , subq_0.ds_partitioned__quarter - , subq_0.ds_partitioned__year - , subq_0.ds_partitioned__extract_year - , subq_0.ds_partitioned__extract_quarter - , subq_0.ds_partitioned__extract_month - , subq_0.ds_partitioned__extract_day - , subq_0.ds_partitioned__extract_dow - , subq_0.ds_partitioned__extract_doy - , subq_0.paid_at__day - , subq_0.paid_at__week - , subq_0.paid_at__month - , subq_0.paid_at__quarter - , subq_0.paid_at__year - , subq_0.paid_at__extract_year - , subq_0.paid_at__extract_quarter - , subq_0.paid_at__extract_month - , subq_0.paid_at__extract_day - , subq_0.paid_at__extract_dow - , subq_0.paid_at__extract_doy - , subq_0.booking__ds__day - , subq_0.booking__ds__week - , subq_0.booking__ds__month - , subq_0.booking__ds__quarter - , subq_0.booking__ds__year - , subq_0.booking__ds__extract_year - , subq_0.booking__ds__extract_quarter - , subq_0.booking__ds__extract_month - , subq_0.booking__ds__extract_day - , subq_0.booking__ds__extract_dow - , subq_0.booking__ds__extract_doy - , subq_0.booking__ds_partitioned__day - , subq_0.booking__ds_partitioned__week - , subq_0.booking__ds_partitioned__month - , subq_0.booking__ds_partitioned__quarter - , subq_0.booking__ds_partitioned__year - , subq_0.booking__ds_partitioned__extract_year - , subq_0.booking__ds_partitioned__extract_quarter - , subq_0.booking__ds_partitioned__extract_month - , subq_0.booking__ds_partitioned__extract_day - , subq_0.booking__ds_partitioned__extract_dow - , subq_0.booking__ds_partitioned__extract_doy - , subq_0.booking__paid_at__day - , subq_0.booking__paid_at__week - , subq_0.booking__paid_at__month - , subq_0.booking__paid_at__quarter - , subq_0.booking__paid_at__year - , subq_0.booking__paid_at__extract_year - , subq_0.booking__paid_at__extract_quarter - , subq_0.booking__paid_at__extract_month - , subq_0.booking__paid_at__extract_day - , subq_0.booking__paid_at__extract_dow - , subq_0.booking__paid_at__extract_doy - , subq_0.ds__day AS metric_time__day - , subq_0.ds__week AS metric_time__week - , subq_0.ds__month AS metric_time__month - , subq_0.ds__quarter AS metric_time__quarter - , subq_0.ds__year AS metric_time__year - , subq_0.ds__extract_year AS metric_time__extract_year - , subq_0.ds__extract_quarter AS metric_time__extract_quarter - , subq_0.ds__extract_month AS metric_time__extract_month - , subq_0.ds__extract_day AS metric_time__extract_day - , subq_0.ds__extract_dow AS metric_time__extract_dow - , subq_0.ds__extract_doy AS metric_time__extract_doy - , subq_0.listing - , subq_0.guest - , subq_0.host - , subq_0.booking__listing - , subq_0.booking__guest - , subq_0.booking__host - , subq_0.is_instant - , subq_0.booking__is_instant - , subq_0.bookings - , subq_0.instant_bookings - , subq_0.booking_value - , subq_0.max_booking_value - , subq_0.min_booking_value - , subq_0.bookers - , subq_0.average_booking_value - , subq_0.referred_bookings - , subq_0.median_booking_value - , subq_0.booking_value_p99 - , subq_0.discrete_booking_value_p99 - , subq_0.approximate_continuous_booking_value_p99 - , subq_0.approximate_discrete_booking_value_p99 - FROM ( - -- Read Elements From Semantic Model 'bookings_source' - SELECT - 1 AS bookings - , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings - , bookings_source_src_28000.booking_value - , bookings_source_src_28000.booking_value AS max_booking_value - , bookings_source_src_28000.booking_value AS min_booking_value - , bookings_source_src_28000.guest_id AS bookers - , bookings_source_src_28000.booking_value AS average_booking_value - , bookings_source_src_28000.booking_value AS booking_payments - , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings - , bookings_source_src_28000.booking_value AS median_booking_value - , bookings_source_src_28000.booking_value AS booking_value_p99 - , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 - , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 - , bookings_source_src_28000.is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy - , bookings_source_src_28000.is_instant AS booking__is_instant - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day - , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week - , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year - , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day - , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week - , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month - , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter - , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year - , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month - , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy - , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day - , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week - , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month - , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter - , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year - , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year - , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter - , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month - , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day - , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow - , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy - , bookings_source_src_28000.listing_id AS listing - , bookings_source_src_28000.guest_id AS guest - , bookings_source_src_28000.host_id AS host - , bookings_source_src_28000.listing_id AS booking__listing - , bookings_source_src_28000.guest_id AS booking__guest - , bookings_source_src_28000.host_id AS booking__host - FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_0 - ) subq_1 - ) subq_2 + 1 AS bookings + , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings + , bookings_source_src_28000.booking_value + , bookings_source_src_28000.booking_value AS max_booking_value + , bookings_source_src_28000.booking_value AS min_booking_value + , bookings_source_src_28000.guest_id AS bookers + , bookings_source_src_28000.booking_value AS average_booking_value + , bookings_source_src_28000.booking_value AS booking_payments + , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings + , bookings_source_src_28000.booking_value AS median_booking_value + , bookings_source_src_28000.booking_value AS booking_value_p99 + , bookings_source_src_28000.booking_value AS discrete_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_continuous_booking_value_p99 + , bookings_source_src_28000.booking_value AS approximate_discrete_booking_value_p99 + , bookings_source_src_28000.is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS paid_at__extract_doy + , bookings_source_src_28000.is_instant AS booking__is_instant + , DATE_TRUNC('day', bookings_source_src_28000.ds) AS booking__ds__day + , DATE_TRUNC('week', bookings_source_src_28000.ds) AS booking__ds__week + , DATE_TRUNC('month', bookings_source_src_28000.ds) AS booking__ds__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds) AS booking__ds__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds) AS booking__ds__year + , EXTRACT(year FROM bookings_source_src_28000.ds) AS booking__ds__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds) AS booking__ds__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds) AS booking__ds__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds) AS booking__ds__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds) AS booking__ds__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds) AS booking__ds__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__day + , DATE_TRUNC('week', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__week + , DATE_TRUNC('month', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__month + , DATE_TRUNC('quarter', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__quarter + , DATE_TRUNC('year', bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__year + , EXTRACT(year FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_month + , EXTRACT(day FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.ds_partitioned) AS booking__ds_partitioned__extract_doy + , DATE_TRUNC('day', bookings_source_src_28000.paid_at) AS booking__paid_at__day + , DATE_TRUNC('week', bookings_source_src_28000.paid_at) AS booking__paid_at__week + , DATE_TRUNC('month', bookings_source_src_28000.paid_at) AS booking__paid_at__month + , DATE_TRUNC('quarter', bookings_source_src_28000.paid_at) AS booking__paid_at__quarter + , DATE_TRUNC('year', bookings_source_src_28000.paid_at) AS booking__paid_at__year + , EXTRACT(year FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_year + , EXTRACT(quarter FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_quarter + , EXTRACT(month FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_month + , EXTRACT(day FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_day + , EXTRACT(DAY_OF_WEEK FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_dow + , EXTRACT(doy FROM bookings_source_src_28000.paid_at) AS booking__paid_at__extract_doy + , bookings_source_src_28000.listing_id AS listing + , bookings_source_src_28000.guest_id AS guest + , bookings_source_src_28000.host_id AS host + , bookings_source_src_28000.listing_id AS booking__listing + , bookings_source_src_28000.guest_id AS booking__guest + , bookings_source_src_28000.host_id AS booking__host + FROM ***************************.fct_bookings bookings_source_src_28000 + ) subq_0 + ) subq_1 WHERE booking__is_instant - ) subq_3 - ) subq_4 + ) subq_2 + ) subq_3 GROUP BY - subq_4.metric_time__day - ) subq_5 + subq_3.metric_time__day + ) subq_4 ON - subq_6.metric_time__day = subq_5.metric_time__day -) subq_8 + subq_5.metric_time__day = subq_4.metric_time__day +) subq_7 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 1185bf668d..7db2cc2894 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,9 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day - , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + subq_14.ds AS metric_time__day + , subq_12.bookings AS bookings + FROM ***************************.mf_time_spine subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'metric_time__day'] @@ -18,17 +18,16 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_9 WHERE booking__is_instant GROUP BY metric_time__day - ) subq_14 + ) subq_12 ON - subq_16.ds = subq_14.metric_time__day -) subq_17 + subq_14.ds = subq_12.metric_time__day +) subq_15 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 7fe5de84a9..27ea74cbc7 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -28,17 +28,112 @@ FROM ( , subq_3.booking__is_instant , SUM(subq_3.bookings) AS bookings FROM ( - -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT subq_2.metric_time__day , subq_2.booking__is_instant , subq_2.bookings FROM ( - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] + -- Constrain Output with WHERE SELECT - subq_1.metric_time__day + subq_1.ds__day + , subq_1.ds__week + , subq_1.ds__month + , subq_1.ds__quarter + , subq_1.ds__year + , subq_1.ds__extract_year + , subq_1.ds__extract_quarter + , subq_1.ds__extract_month + , subq_1.ds__extract_day + , subq_1.ds__extract_dow + , subq_1.ds__extract_doy + , subq_1.ds_partitioned__day + , subq_1.ds_partitioned__week + , subq_1.ds_partitioned__month + , subq_1.ds_partitioned__quarter + , subq_1.ds_partitioned__year + , subq_1.ds_partitioned__extract_year + , subq_1.ds_partitioned__extract_quarter + , subq_1.ds_partitioned__extract_month + , subq_1.ds_partitioned__extract_day + , subq_1.ds_partitioned__extract_dow + , subq_1.ds_partitioned__extract_doy + , subq_1.paid_at__day + , subq_1.paid_at__week + , subq_1.paid_at__month + , subq_1.paid_at__quarter + , subq_1.paid_at__year + , subq_1.paid_at__extract_year + , subq_1.paid_at__extract_quarter + , subq_1.paid_at__extract_month + , subq_1.paid_at__extract_day + , subq_1.paid_at__extract_dow + , subq_1.paid_at__extract_doy + , subq_1.booking__ds__day + , subq_1.booking__ds__week + , subq_1.booking__ds__month + , subq_1.booking__ds__quarter + , subq_1.booking__ds__year + , subq_1.booking__ds__extract_year + , subq_1.booking__ds__extract_quarter + , subq_1.booking__ds__extract_month + , subq_1.booking__ds__extract_day + , subq_1.booking__ds__extract_dow + , subq_1.booking__ds__extract_doy + , subq_1.booking__ds_partitioned__day + , subq_1.booking__ds_partitioned__week + , subq_1.booking__ds_partitioned__month + , subq_1.booking__ds_partitioned__quarter + , subq_1.booking__ds_partitioned__year + , subq_1.booking__ds_partitioned__extract_year + , subq_1.booking__ds_partitioned__extract_quarter + , subq_1.booking__ds_partitioned__extract_month + , subq_1.booking__ds_partitioned__extract_day + , subq_1.booking__ds_partitioned__extract_dow + , subq_1.booking__ds_partitioned__extract_doy + , subq_1.booking__paid_at__day + , subq_1.booking__paid_at__week + , subq_1.booking__paid_at__month + , subq_1.booking__paid_at__quarter + , subq_1.booking__paid_at__year + , subq_1.booking__paid_at__extract_year + , subq_1.booking__paid_at__extract_quarter + , subq_1.booking__paid_at__extract_month + , subq_1.booking__paid_at__extract_day + , subq_1.booking__paid_at__extract_dow + , subq_1.booking__paid_at__extract_doy + , subq_1.metric_time__day + , subq_1.metric_time__week + , subq_1.metric_time__month + , subq_1.metric_time__quarter + , subq_1.metric_time__year + , subq_1.metric_time__extract_year + , subq_1.metric_time__extract_quarter + , subq_1.metric_time__extract_month + , subq_1.metric_time__extract_day + , subq_1.metric_time__extract_dow + , subq_1.metric_time__extract_doy + , subq_1.listing + , subq_1.guest + , subq_1.host + , subq_1.booking__listing + , subq_1.booking__guest + , subq_1.booking__host + , subq_1.is_instant , subq_1.booking__is_instant , subq_1.bookings + , subq_1.instant_bookings + , subq_1.booking_value + , subq_1.max_booking_value + , subq_1.min_booking_value + , subq_1.bookers + , subq_1.average_booking_value + , subq_1.referred_bookings + , subq_1.median_booking_value + , subq_1.booking_value_p99 + , subq_1.discrete_booking_value_p99 + , subq_1.approximate_continuous_booking_value_p99 + , subq_1.approximate_discrete_booking_value_p99 FROM ( -- Metric Time Dimension 'ds' SELECT @@ -234,8 +329,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_0 ) subq_1 + WHERE booking__is_instant ) subq_2 - WHERE booking__is_instant ) subq_3 GROUP BY subq_3.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 476eccde2c..19f81cdd9b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -18,6 +18,7 @@ FROM ( FROM ***************************.mf_time_spine subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE + -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] -- Aggregate Measures SELECT metric_time__day @@ -26,13 +27,12 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' - -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_28000 - ) subq_11 + ) subq_10 WHERE booking__is_instant GROUP BY metric_time__day